<commit_before>#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/thread/mutex.hpp>
#include <chrono>
#include <memory>

namespace boost {
    namespace asio { class io_service; }
}

//=============================================================================
namespace riak {
//=============================================================================

class request_with_timeout
      : public std::enable_shared_from_this<request_with_timeout>
{
  public:
    typedef std::function<void(const boost::system::error_code&, std::size_t, boost::asio::streambuf&)> response_handler;

    /*!
     * Packages a task, but does not send it or begin any timeout counting.
     * \param timeout is in milliseconds.
     */
    request_with_timeout (
            const std::string& data,
            std::chrono::milliseconds timeout,
            boost::asio::ip::tcp::socket& s,
            response_handler& h,
            boost::asio::io_service& ios);

    /*!
     * Sends the request and begins listening for a response asynchronously. Timeout countdown starts now.
     * \pre There must exist a shared pointer to this request at the time of dispatch. It may be
     *     reset as soon as the request is dispatched.
     */
    void dispatch ();

  private:
    void on_response (const boost::system::error_code&, std::size_t);
    void on_timeout (const boost::system::error_code&);
    void on_write (const boost::system::error_code&, std::size_t);

    mutable boost::mutex mutex_;
    boost::asio::ip::tcp::socket& socket_;
    std::chrono::milliseconds timeout_length_;
    boost::asio::deadline_timer timeout_;
    response_handler response_callback_;
    const std::string request_data_;
    boost::asio::streambuf response_data_;

    bool succeeded_;
    bool timed_out_;
};

//=============================================================================
}   // namespace riak
//=============================================================================
<commit_msg>Removed a dependency on boost DateTime.<commit_after>#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/thread/mutex.hpp>
#include <chrono>
#include <memory>

namespace boost {
    namespace asio { class io_service; }
}

//=============================================================================
namespace riak {
//=============================================================================

class request_with_timeout
      : public std::enable_shared_from_this<request_with_timeout>
{
  public:
    typedef std::function<void(const boost::system::error_code&, std::size_t, boost::asio::streambuf&)> response_handler;

    /*!
     * Packages a task, but does not send it or begin any timeout counting.
     * \param timeout is in milliseconds.
     */
    request_with_timeout (
            const std::string& data,
            std::chrono::milliseconds timeout,
            boost::asio::ip::tcp::socket& s,
            response_handler& h,
            boost::asio::io_service& ios);

    /*!
     * Sends the request and begins listening for a response asynchronously. Timeout countdown starts now.
     * \pre There must exist a shared pointer to this request at the time of dispatch. It may be
     *     reset as soon as the request is dispatched.
     */
    void dispatch ();

  private:
    void on_response (const boost::system::error_code&, std::size_t);
    void on_timeout (const boost::system::error_code&);
    void on_write (const boost::system::error_code&, std::size_t);

    mutable boost::mutex mutex_;
    boost::asio::ip::tcp::socket& socket_;
    std::chrono::milliseconds timeout_length_;
    boost::asio::deadline_timer timeout_;
    response_handler response_callback_;
    const std::string request_data_;
    boost::asio::streambuf response_data_;

    bool succeeded_;
    bool timed_out_;
};

//=============================================================================
}   // namespace riak
//=============================================================================
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: border.hxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: hr $ $Date: 2007-06-27 16:49:40 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _SVX_BORDER_HXX
#define _SVX_BORDER_HXX

// include ---------------------------------------------------------------

#ifndef _CTRLBOX_HXX //autogen
#include <svtools/ctrlbox.hxx>
#endif
#ifndef _GROUP_HXX //autogen
#include <vcl/group.hxx>
#endif
#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif
#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _VALUESET_HXX //autogen
#include <svtools/valueset.hxx>
#endif
#ifndef _SFXTABDLG_HXX //autogen
#include <sfx2/tabdlg.hxx>
#endif
#ifndef SVX_FRMSEL_HXX
#include <svx/frmsel.hxx>
#endif
// forward ---------------------------------------------------------------

class SvxBorderLine;
class XColorTable;

// class SvxBorderTabPage ------------------------------------------------
/*
{k:\svx\prototyp\dialog\border.bmp}
[Beschreibung]
TabPage zur Einstellung der Umrandung (Staerke, Farbe, Schatten, ...)
[Items]
<SvxBoxItem><SID_ATTR_BORDER_OUTER>
<SvxBoxInfoItem><SID_ATTR_BORDER_INNER>
<SvxShadowItem><SID_ATTR_BORDER_SHADOW>
*/

// Border-Modes for paragraphs, textframes and tables
//CHINA001 #define SW_BORDER_MODE_PARA  0x01
//CHINA001 #define SW_BORDER_MODE_TABLE    0x02
//CHINA001 #define SW_BORDER_MODE_FRAME    0x04
#include "flagsdef.hxx"//CHINA001

class SvxBorderTabPage : public SfxTabPage
{
    using TabPage::DeactivatePage;

public:
    static SfxTabPage*  Create( Window* pParent,
                                const SfxItemSet& rAttrSet);
    static USHORT*      GetRanges();

    virtual BOOL        FillItemSet( SfxItemSet& rCoreAttrs );
    virtual void        Reset( const SfxItemSet& );

    void                HideShadowControls();
    virtual void        PageCreated (SfxAllItemSet aSet); //add CHINA001
protected:
    virtual int         DeactivatePage( SfxItemSet* pSet = 0 );
    virtual void        DataChanged( const DataChangedEvent& rDCEvt );

private:
    SvxBorderTabPage( Window* pParent, const SfxItemSet& rCoreAttrs );
    ~SvxBorderTabPage();

    // Controls
    FixedLine           aFlBorder;
    FixedText           aDefaultFT;
    ValueSet            aWndPresets;
    FixedText           aUserDefFT;
    svx::FrameSelector  aFrameSel;

    FixedLine           aFlSep1;
    FixedLine           aFlLine;
    FixedText           aStyleFT;
    LineListBox         aLbLineStyle;
    FixedText           aColorFT;
    ColorListBox        aLbLineColor;

    FixedLine           aFlSep2;
    FixedLine           aDistanceFL;
    FixedText           aLeftFT;
    MetricField         aLeftMF;
    FixedText           aRightFT;
    MetricField         aRightMF;
    FixedText           aTopFT;
    MetricField         aTopMF;
    FixedText           aBottomFT;
    MetricField         aBottomMF;
    CheckBox            aSynchronizeCB;

    FixedLine           aFlShadow;
    FixedText           aFtShadowPos;
    ValueSet            aWndShadows;
    FixedText           aFtShadowSize;
    MetricField         aEdShadowSize;
    FixedText           aFtShadowColor;
    ColorListBox        aLbShadowColor;

    //properties - "Merge with next paragraph" in Writer
    FixedLine           aPropertiesFL;
    CheckBox            aMergeWithNextCB;
    // --> collapsing table borders FME 2005-05-27 #i29550#
    CheckBox            aMergeAdjacentBordersCB;
    // <--

    ImageList           aShadowImgLstH;
    ImageList           aShadowImgLst;
    ImageList           aBorderImgLstH;
    ImageList           aBorderImgLst;

    long                nMinValue;  // minimum distance
    int                 nSWMode;    // table, textframe, paragraph

    bool                mbHorEnabled;       /// true = Inner horizontal border enabled.
    bool                mbVerEnabled;       /// true = Inner vertical border enabled.
    bool                mbTLBREnabled;      /// true = Top-left to bottom-right border enabled.
    bool                mbBLTREnabled;      /// true = Bottom-left to top-right border enabled.
    bool                mbUseMarginItem;

    static BOOL         bSync;

#ifdef _SVX_BORDER_CXX
    // Handler
    DECL_LINK( SelStyleHdl_Impl, ListBox* pLb );
    DECL_LINK( SelColHdl_Impl, ListBox* pLb );
    DECL_LINK( SelPreHdl_Impl, void* );
    DECL_LINK( SelSdwHdl_Impl, void* );
    DECL_LINK( LinesChanged_Impl, void* );
    DECL_LINK( ModifyDistanceHdl_Impl, MetricField*);
    DECL_LINK( SyncHdl_Impl, CheckBox*);

    USHORT              GetPresetImageId( USHORT nValueSetIdx ) const;
    USHORT              GetPresetStringId( USHORT nValueSetIdx ) const;

    void                FillPresetVS();
    void                FillShadowVS();
    void                FillValueSets();

    // Filler
    void                FillLineListBox_Impl();

    // Setzen von einzelnen Frame-/Core-Linien
    void                ResetFrameLine_Impl( svx::FrameBorderType eBorder,
                                             const SvxBorderLine* pCurLine,
                                             bool bValid );
#endif
};

#endif

<commit_msg>INTEGRATION: CWS changefileheader (1.7.368); FILE MERGED 2008/04/01 15:50:13 thb 1.7.368.3: #i85898# Stripping all external header guards 2008/04/01 12:48:05 thb 1.7.368.2: #i85898# Stripping all external header guards 2008/03/31 14:19:19 rt 1.7.368.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: border.hxx,v $
 * $Revision: 1.8 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _SVX_BORDER_HXX
#define _SVX_BORDER_HXX

// include ---------------------------------------------------------------

#include <svtools/ctrlbox.hxx>
#ifndef _GROUP_HXX //autogen
#include <vcl/group.hxx>
#endif
#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif
#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#include <svtools/valueset.hxx>
#include <sfx2/tabdlg.hxx>
#include <svx/frmsel.hxx>
// forward ---------------------------------------------------------------

class SvxBorderLine;
class XColorTable;

// class SvxBorderTabPage ------------------------------------------------
/*
{k:\svx\prototyp\dialog\border.bmp}
[Beschreibung]
TabPage zur Einstellung der Umrandung (Staerke, Farbe, Schatten, ...)
[Items]
<SvxBoxItem><SID_ATTR_BORDER_OUTER>
<SvxBoxInfoItem><SID_ATTR_BORDER_INNER>
<SvxShadowItem><SID_ATTR_BORDER_SHADOW>
*/

// Border-Modes for paragraphs, textframes and tables
//CHINA001 #define SW_BORDER_MODE_PARA  0x01
//CHINA001 #define SW_BORDER_MODE_TABLE    0x02
//CHINA001 #define SW_BORDER_MODE_FRAME    0x04
#include "flagsdef.hxx"//CHINA001

class SvxBorderTabPage : public SfxTabPage
{
    using TabPage::DeactivatePage;

public:
    static SfxTabPage*  Create( Window* pParent,
                                const SfxItemSet& rAttrSet);
    static USHORT*      GetRanges();

    virtual BOOL        FillItemSet( SfxItemSet& rCoreAttrs );
    virtual void        Reset( const SfxItemSet& );

    void                HideShadowControls();
    virtual void        PageCreated (SfxAllItemSet aSet); //add CHINA001
protected:
    virtual int         DeactivatePage( SfxItemSet* pSet = 0 );
    virtual void        DataChanged( const DataChangedEvent& rDCEvt );

private:
    SvxBorderTabPage( Window* pParent, const SfxItemSet& rCoreAttrs );
    ~SvxBorderTabPage();

    // Controls
    FixedLine           aFlBorder;
    FixedText           aDefaultFT;
    ValueSet            aWndPresets;
    FixedText           aUserDefFT;
    svx::FrameSelector  aFrameSel;

    FixedLine           aFlSep1;
    FixedLine           aFlLine;
    FixedText           aStyleFT;
    LineListBox         aLbLineStyle;
    FixedText           aColorFT;
    ColorListBox        aLbLineColor;

    FixedLine           aFlSep2;
    FixedLine           aDistanceFL;
    FixedText           aLeftFT;
    MetricField         aLeftMF;
    FixedText           aRightFT;
    MetricField         aRightMF;
    FixedText           aTopFT;
    MetricField         aTopMF;
    FixedText           aBottomFT;
    MetricField         aBottomMF;
    CheckBox            aSynchronizeCB;

    FixedLine           aFlShadow;
    FixedText           aFtShadowPos;
    ValueSet            aWndShadows;
    FixedText           aFtShadowSize;
    MetricField         aEdShadowSize;
    FixedText           aFtShadowColor;
    ColorListBox        aLbShadowColor;

    //properties - "Merge with next paragraph" in Writer
    FixedLine           aPropertiesFL;
    CheckBox            aMergeWithNextCB;
    // --> collapsing table borders FME 2005-05-27 #i29550#
    CheckBox            aMergeAdjacentBordersCB;
    // <--

    ImageList           aShadowImgLstH;
    ImageList           aShadowImgLst;
    ImageList           aBorderImgLstH;
    ImageList           aBorderImgLst;

    long                nMinValue;  // minimum distance
    int                 nSWMode;    // table, textframe, paragraph

    bool                mbHorEnabled;       /// true = Inner horizontal border enabled.
    bool                mbVerEnabled;       /// true = Inner vertical border enabled.
    bool                mbTLBREnabled;      /// true = Top-left to bottom-right border enabled.
    bool                mbBLTREnabled;      /// true = Bottom-left to top-right border enabled.
    bool                mbUseMarginItem;

    static BOOL         bSync;

#ifdef _SVX_BORDER_CXX
    // Handler
    DECL_LINK( SelStyleHdl_Impl, ListBox* pLb );
    DECL_LINK( SelColHdl_Impl, ListBox* pLb );
    DECL_LINK( SelPreHdl_Impl, void* );
    DECL_LINK( SelSdwHdl_Impl, void* );
    DECL_LINK( LinesChanged_Impl, void* );
    DECL_LINK( ModifyDistanceHdl_Impl, MetricField*);
    DECL_LINK( SyncHdl_Impl, CheckBox*);

    USHORT              GetPresetImageId( USHORT nValueSetIdx ) const;
    USHORT              GetPresetStringId( USHORT nValueSetIdx ) const;

    void                FillPresetVS();
    void                FillShadowVS();
    void                FillValueSets();

    // Filler
    void                FillLineListBox_Impl();

    // Setzen von einzelnen Frame-/Core-Linien
    void                ResetFrameLine_Impl( svx::FrameBorderType eBorder,
                                             const SvxBorderLine* pCurLine,
                                             bool bValid );
#endif
};

#endif

<|endoftext|>


<commit_before>/*
Some numbers:
Max ActorID: 1971696
NRows: 17316773-1
Max MovieID: 1151758
*/

#include <iostream>
#include <ios>
#include <fstream>
#include <vector>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <list>
#include <thread>

using namespace std;

// BAD CODING!!! <3
int *actor_keys = new int[1971696];
int *act2mov_actors = new int[1971696];
int *act2mov_movies = new int[17316773-1];
int *mov2act_movies = new int[1151758];
int *mov2act_actors = new int[17316773-1]();

// Breadth-First Search
int BFS(
        int *act2mov_actors,
        int *act2mov_movies,
        int *mov2act_movies,
        int *mov2act_actors,
        int actorid2,
        vector<int> current_nodes,
        bool *actor_visited,
        bool *movie_visited
    ) {
    /*
    Iterate over the current nodes.
    For each actor find all movies.
    If we visited the movie already skip it, otherwise find all actors in that movie.
    Add the actors we did not look at already to the neighbourhood.
    Swap neighbours and current_nodes and start again.
    */

    vector<int> neighbours;
    int depth = 0;

    while(!current_nodes.empty()){
        depth++;
        for(int i : current_nodes) {
            for(int j = act2mov_actors[i-1]; j < act2mov_actors[i]; j++) {
                int movie = act2mov_movies[j];
                if(!movie_visited[movie]){
                    movie_visited[movie] = 1;
                    for(int k=mov2act_movies[movie-1]; k<mov2act_movies[movie]; k++){
                        int new_actor = mov2act_actors[k];
                        if(!actor_visited[new_actor]) {
                            if(new_actor==actorid2){
                                return depth;
                            }
                            actor_visited[new_actor] = 1;
                            neighbours.push_back(new_actor);
                        }
                    }
                }
            }
        }

    current_nodes.swap(neighbours);
    neighbours.clear();
    }

    return -1;
}

void BFSThread(int thread_a1, int thread_a2, int *dist_thread, int i){

    if(thread_a1 == thread_a2){
            dist_thread[i] = 0;
            return;
    }

    // Boolean arrays to save which has been visited
    bool *actor_visited = new bool[1971696+1]();
    bool *movie_visited = new bool[1151758+1]();

    // We start with only actor 1 on the current node
    vector<int> current_nodes;
    current_nodes.push_back(actor_keys[thread_a1]);
    // Start Breadth-First-Search
    int dist;
    dist = BFS(
        act2mov_actors, act2mov_movies,
        mov2act_movies, mov2act_actors,
        actor_keys[thread_a2], current_nodes, actor_visited, movie_visited);
    cout << "Process: " << i << " Distance: " << dist << endl;
    dist_thread[i] = dist;

    // delete unsused variable
    delete[] actor_visited;
    delete[] movie_visited;
}

int main(int argc, char** argv) {

    // Movie to actor map - Will be replaced later
    vector<vector<int>> M(1151758+1);

    // Open file and figre out length
    int handle = open(argv[1],O_RDONLY);
    if (handle<0) return 1;
    lseek(handle,0,SEEK_END);
    long length = lseek(handle,0,SEEK_CUR);

    // Map file into address space
    auto data = static_cast<const char*>(mmap(nullptr,length,PROT_READ,MAP_SHARED,handle,0));
    auto dataLimit = data + length;

    /* Read file and create our datatypes
    We store the actor to movie relation in a CSR and movie to actor in a map
    */
    const char* line = data;
    int actor_index = -1;
    int current_line = 0;
    int last_actor = 0;
    for (const char* current=data;current!=dataLimit;) {
        const char* last=line;
        unsigned column=0;
        int actor=0;
        int movie=0;
        for (;current!=dataLimit;++current) {
            char c=*current;
            if (c==',') {
                    last=current+1;
                    ++column;
            }else if (c=='\n') {
                /* Check if the actor is different to the last one
                If yes increase actor_index and add entry to actor_keys */
                if(actor != last_actor){
                    last_actor = actor;
                    act2mov_actors[actor_index] = current_line;
                    ++actor_index;
                    actor_keys[actor] = actor_index;
                }

                // Insert entry into Movie->Actor Map
                M[movie].push_back(actor_index);

                // Insert movie to list
                act2mov_movies[current_line] = movie;

                // Update index
                ++current_line;

                ++current;
                break;
            }else if (column==0) {
                    actor=10*actor+c-'0';
            }else if (column==1) {
                    movie=10*movie+c-'0';
            }
        }
    }
    act2mov_actors[actor_index] = current_line;

    cout << "File eingelesen" << endl;

    // Create CSR for movie to actor relation
    int iterator = 0;
    for(int movie_id=1; movie_id<=1151758; movie_id++){
        for(int actor : M.at(movie_id)){
            mov2act_actors[iterator] = actor;
	       ++iterator;
        }
        mov2act_movies[movie_id] = iterator;
    }

    // While there is an input: read, store, compute
    int actorid1;
    int actorid2;
    vector<int> actor1;
    vector<int> actor2;

    while((cin >> actorid1) && (cin >> actorid2)) {
        actor1.push_back(actorid1);
        actor2.push_back(actorid2);
    }

    int inputlen = actor1.size();
    int *distance = new int[inputlen];
    thread *thread_arr = new thread[inputlen];
    for(int time_counter = 0; time_counter<1; ++time_counter){
        for(int i=0; i < inputlen; i++){
            thread_arr[i] = thread(BFSThread, actor1[i], actor2[i], distance, i);
        }
        cout << "Threading started" << endl;
        for(int i=0; i < inputlen; i++){
            thread_arr[i].join();
        }
    }

    for(int j=0; j<inputlen; j++){
        cout << distance[j] << endl;
    }
    return 0;
}
<commit_msg>final lookin' good!<commit_after>/*
Some numbers:
Max ActorID: 1971696
NRows: 17316773-1
Max MovieID: 1151758
*/

#include <iostream>
#include <vector>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <thread>

using namespace std;

// BAD CODING!!! <3
int *actor_keys = new int[1971696];
int *act2mov_actors = new int[1971696];
int *act2mov_movies = new int[17316773-1];
int *mov2act_movies = new int[1151758];
int *mov2act_actors = new int[17316773-1]();

// Breadth-First Search
int BFS(
        int *act2mov_actors,
        int *act2mov_movies,
        int *mov2act_movies,
        int *mov2act_actors,
        int actorid2,
        vector<int> current_nodes,
        bool *actor_visited,
        bool *movie_visited
    ) {
    /*
    Iterate over the current nodes.
    For each actor find all movies.
    If we visited the movie already skip it, otherwise find all actors in that movie.
    Add the actors we did not look at already to the neighbourhood.
    Swap neighbours and current_nodes and start again.
    */

    vector<int> neighbours;
    int depth = 0;

    while(!current_nodes.empty()){
        depth++;
        for(int i : current_nodes) {
            for(int j = act2mov_actors[i-1]; j < act2mov_actors[i]; j++) {
                int movie = act2mov_movies[j];
                if(!movie_visited[movie]){
                    movie_visited[movie] = 1;
                    for(int k=mov2act_movies[movie-1]; k<mov2act_movies[movie]; k++){
                        int new_actor = mov2act_actors[k];
                        if(!actor_visited[new_actor]) {
                            if(new_actor==actorid2){
                                return depth;
                            }
                            actor_visited[new_actor] = 1;
                            neighbours.push_back(new_actor);
                        }
                    }
                }
            }
        }

    current_nodes.swap(neighbours);
    neighbours.clear();
    }

    return -1;
}

void BFSThread(int thread_a1, int thread_a2, int *dist_thread, int i){

    if(thread_a1 == thread_a2){
            dist_thread[i] = 0;
            return;
    }

    // Boolean arrays to save which has been visited
    bool *actor_visited = new bool[1971696+1]();
    bool *movie_visited = new bool[1151758+1]();

    // We start with only actor 1 on the current node
    vector<int> current_nodes;
    current_nodes.push_back(actor_keys[thread_a1]);
    // Start Breadth-First-Search
    int dist;
    dist = BFS(
        act2mov_actors, act2mov_movies,
        mov2act_movies, mov2act_actors,
        actor_keys[thread_a2], current_nodes, actor_visited, movie_visited);
    // cout << "Process: " << i << " Distance: " << dist << endl;
    dist_thread[i] = dist;

    // delete unsused variable
    delete[] actor_visited;
    delete[] movie_visited;
}

int main(int argc, char** argv) {

    // Movie to actor map - Will be replaced later
    vector<vector<int>> M(1151758+1);

    // Open file and figre out length
    int handle = open(argv[1],O_RDONLY);
    if (handle<0) return 1;
    lseek(handle,0,SEEK_END);
    long length = lseek(handle,0,SEEK_CUR);

    // Map file into address space
    auto data = static_cast<const char*>(mmap(nullptr,length,PROT_READ,MAP_SHARED,handle,0));
    auto dataLimit = data + length;

    /* Read file and create our datatypes
    We store the actor to movie relation in a CSR and movie to actor in a map
    */
    const char* line = data;
    int actor_index = -1;
    int current_line = 0;
    int last_actor = 0;
    for (const char* current=data;current!=dataLimit;) {
        const char* last=line;
        unsigned column=0;
        int actor=0;
        int movie=0;
        for (;current!=dataLimit;++current) {
            char c=*current;
            if (c==',') {
                    last=current+1;
                    ++column;
            }else if (c=='\n') {
                /* Check if the actor is different to the last one
                If yes increase actor_index and add entry to actor_keys */
                if(actor != last_actor){
                    last_actor = actor;
                    act2mov_actors[actor_index] = current_line;
                    ++actor_index;
                    actor_keys[actor] = actor_index;
                }

                // Insert entry into Movie->Actor Map
                M[movie].push_back(actor_index);

                // Insert movie to list
                act2mov_movies[current_line] = movie;

                // Update index
                ++current_line;

                ++current;
                break;
            }else if (column==0) {
                    actor=10*actor+c-'0';
            }else if (column==1) {
                    movie=10*movie+c-'0';
            }
        }
    }
    act2mov_actors[actor_index] = current_line;

    // cout << "File eingelesen" << endl;

    // Create CSR for movie to actor relation
    int iterator = 0;
    for(int movie_id=1; movie_id<=1151758; movie_id++){
        for(int actor : M.at(movie_id)){
            mov2act_actors[iterator] = actor;
	       ++iterator;
        }
        mov2act_movies[movie_id] = iterator;
    }

    // While there is an input: read, store, compute
    int actorid1;
    int actorid2;
    vector<int> actor1;
    vector<int> actor2;

    while((cin >> actorid1) && (cin >> actorid2)) {
        actor1.push_back(actorid1);
        actor2.push_back(actorid2);
    }

    int inputlen = actor1.size();
    int *distance = new int[inputlen];
    thread *thread_arr = new thread[inputlen];
    for(int time_counter = 0; time_counter<1; ++time_counter){
        for(int i=0; i < inputlen; i++){
            thread_arr[i] = thread(BFSThread, actor1[i], actor2[i], distance, i);
        }
        // cout << "Threading started" << endl;
        for(int i=0; i < inputlen; i++){
            thread_arr[i].join();
        }
    }

    for(int j=0; j<inputlen; j++){
        cout << distance[j] << endl;
    }

    return 0;
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: SwStyleNameMapper.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 08:27:31 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): Martin Gallwey ( gallwey@sun.com )
 *
 *
 ************************************************************************/
#ifndef _SWSTYLENAMEMAPPER_HXX
#define _SWSTYLENAMEMAPPER_HXX

#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#ifndef _GETPOOLIDFROMNAMEENUM_HXX
#include <SwGetPoolIdFromName.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

#ifndef INCLUDED_HASH_MAP
#include <hash_map>
#define INCLUDED_HASH_MAP
#endif

#ifndef _STRINGHASH_HXX
#include <stringhash.hxx>
#endif

/* This class holds all data about the names of styles used in the user
 * interface (UI names...these are localised into different languages).
 * These UI names are loaded from the resource files on demand.
 *
 * It also holds all information about the 'Programmatic' names of styles
 * which remain static (and are hardcoded in the corresponding cxx file)
 * for all languages.
 *
 * This class also provides static functions which can be used for the
 * following conversions:
 *
 * 1. Programmatic Name -> UI Name
 * 2. Programmatic Name -> Pool ID
 * 3. UI Name -> Programmatic Name
 * 4. UI Name -> Pool ID
 * 5. Pool ID -> UI Name
 * 6. Pool ID -> Programmatic Name
 *
 * The relationship of these tables to the style families is as follows:
 *
 * 1. Paragraph contains the Text, Lists, Extra, Register, Doc and HTML
 *    name arrays.
 * 2. Character contains the ChrFmt and HTMLChrFmt name arrays.
 * 3. Page contains the PageDesc name array.
 * 4. Frame contains the FrmFmt name array.
 * 5. Numbering Rule contains the NumRule name array.
 */

/*
 * There is a further complication that came to light later. If someone enters
 * a user-defined style name which is the same as a programmatic name, this
 * name clash must be handled.
 *
 * Therefore, when there is a danger of a nameclash, the boolean bDisambiguate
 * must be set to true in the SwStyleNameMapper call (it defaults to false).
 * This will cause the following to happen:
 *
 * If the UI style name either equals a programmatic name or already ends
 * with " (user)", then it must append " (user)" to the end.
 *
 * When a programmatic name is being converted to a UI name, if it ends in
 * " (user)", we simply remove it.
 */

class SvStringsDtor;
class String;
struct SwTableEntry;

typedef ::std::hash_map < const String*, sal_uInt16, StringHash, StringEq > NameToIdHash;

class SwStyleNameMapper
{
    friend void _InitCore();
    friend void _FinitCore();

protected:
    // UI Name tables
    static SvStringsDtor    *pTextUINameArray,
                            *pListsUINameArray,
                            *pExtraUINameArray,
                            *pRegisterUINameArray,
                            *pDocUINameArray,
                            *pHTMLUINameArray,
                            *pFrmFmtUINameArray,
                            *pChrFmtUINameArray,
                            *pHTMLChrFmtUINameArray,
                            *pPageDescUINameArray,
                            *pNumRuleUINameArray,
    // Programmatic Name tables
                            *pTextProgNameArray,
                            *pListsProgNameArray,
                            *pExtraProgNameArray,
                            *pRegisterProgNameArray,
                            *pDocProgNameArray,
                            *pHTMLProgNameArray,
                            *pFrmFmtProgNameArray,
                            *pChrFmtProgNameArray,
                            *pHTMLChrFmtProgNameArray,
                            *pPageDescProgNameArray,
                            *pNumRuleProgNameArray;

    static NameToIdHash     *pParaUIMap,
                            *pCharUIMap,
                            *pPageUIMap,
                            *pFrameUIMap,
                            *pNumRuleUIMap,

                            *pParaProgMap,
                            *pCharProgMap,
                            *pPageProgMap,
                            *pFrameProgMap,
                            *pNumRuleProgMap;

    static SvStringsDtor* NewUINameArray( SvStringsDtor*&,
                                      sal_uInt16 nStt,
                                      sal_uInt16 nEnd );

    static SvStringsDtor* NewProgNameArray( SvStringsDtor*&,
                                          const SwTableEntry *pTable,
                                          sal_uInt8 nCount);

    static void fillNameFromId ( sal_uInt16 nId, String &rName, sal_Bool bProgName );
    static const String& getNameFromId ( sal_uInt16 nId, const String &rName, sal_Bool bProgName );
    static const NameToIdHash& getHashTable ( SwGetPoolIdFromName, sal_Bool bProgName );
    static sal_Bool SuffixIsUser ( const String & rString );
    static void CheckSuffixAndDelete ( String & rString );

public:
    // This gets the UI Name from the programmatic name
    static const String& GetUIName ( const String& rName, SwGetPoolIdFromName );
    static         void FillUIName ( const String& rName, String& rFillName, SwGetPoolIdFromName, sal_Bool bDisambiguate = sal_False );

    // Get the programmatic Name from the UI name
    static const String& GetProgName ( const String& rName, SwGetPoolIdFromName );
    static         void FillProgName ( const String& rName, String& rFillName, SwGetPoolIdFromName, sal_Bool bDisambiguate = sal_False );

    // This gets the UI Name from the Pool ID
    SW_DLLPUBLIC static          void FillUIName ( sal_uInt16 nId, String& rFillName );
    SW_DLLPUBLIC static const String& GetUIName  ( sal_uInt16 nId, const String& rName );

    // This gets the programmatic Name from the Pool ID
    static          void FillProgName( sal_uInt16 nId, String& rFillName );
    static const String& GetProgName ( sal_uInt16 nId, const String& rName );

    // This gets the PoolId from the UI Name
    SW_DLLPUBLIC static sal_uInt16 GetPoolIdFromUIName( const String& rName, SwGetPoolIdFromName );

    // Get the Pool ID from the programmatic name
    static sal_uInt16 GetPoolIdFromProgName( const String& rName, SwGetPoolIdFromName );

    // used to convert the 4 special ExtraProg/UINames for
    // RES_POOLCOLL_LABEL_DRAWING,  RES_POOLCOLL_LABEL_ABB,
    // RES_POOLCOLL_LABEL_TABLE, RES_POOLCOLL_LABEL_FRAME
    // forth and back.
    // Non-matching names remain unchanged.
    SW_DLLPUBLIC static const String GetSpecialExtraProgName( const String& rExtraUIName );
    static const String GetSpecialExtraUIName( const String& rExtraProgName );

    static const SvStringsDtor& GetTextUINameArray();
    static const SvStringsDtor& GetListsUINameArray();
    static const SvStringsDtor& GetExtraUINameArray();
    static const SvStringsDtor& GetRegisterUINameArray();
    static const SvStringsDtor& GetDocUINameArray();
    static const SvStringsDtor& GetHTMLUINameArray();
    static const SvStringsDtor& GetFrmFmtUINameArray();
    static const SvStringsDtor& GetChrFmtUINameArray();
    static const SvStringsDtor& GetHTMLChrFmtUINameArray();
    static const SvStringsDtor& GetPageDescUINameArray();
    static const SvStringsDtor& GetNumRuleUINameArray();

    static const SvStringsDtor& GetTextProgNameArray();
    static const SvStringsDtor& GetListsProgNameArray();
    static const SvStringsDtor& GetExtraProgNameArray();
    static const SvStringsDtor& GetRegisterProgNameArray();
    static const SvStringsDtor& GetDocProgNameArray();
    static const SvStringsDtor& GetHTMLProgNameArray();
    static const SvStringsDtor& GetFrmFmtProgNameArray();
    static const SvStringsDtor& GetChrFmtProgNameArray();
    static const SvStringsDtor& GetHTMLChrFmtProgNameArray();
    static const SvStringsDtor& GetPageDescProgNameArray();
    static const SvStringsDtor& GetNumRuleProgNameArray();
};
#endif // _NAME_MAPPER_HXX
<commit_msg>INTEGRATION: CWS ooo19126 (1.6.596); FILE MERGED 2005/09/05 13:35:35 rt 1.6.596.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: SwStyleNameMapper.hxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 01:29:53 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _SWSTYLENAMEMAPPER_HXX
#define _SWSTYLENAMEMAPPER_HXX

#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#ifndef _GETPOOLIDFROMNAMEENUM_HXX
#include <SwGetPoolIdFromName.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

#ifndef INCLUDED_HASH_MAP
#include <hash_map>
#define INCLUDED_HASH_MAP
#endif

#ifndef _STRINGHASH_HXX
#include <stringhash.hxx>
#endif

/* This class holds all data about the names of styles used in the user
 * interface (UI names...these are localised into different languages).
 * These UI names are loaded from the resource files on demand.
 *
 * It also holds all information about the 'Programmatic' names of styles
 * which remain static (and are hardcoded in the corresponding cxx file)
 * for all languages.
 *
 * This class also provides static functions which can be used for the
 * following conversions:
 *
 * 1. Programmatic Name -> UI Name
 * 2. Programmatic Name -> Pool ID
 * 3. UI Name -> Programmatic Name
 * 4. UI Name -> Pool ID
 * 5. Pool ID -> UI Name
 * 6. Pool ID -> Programmatic Name
 *
 * The relationship of these tables to the style families is as follows:
 *
 * 1. Paragraph contains the Text, Lists, Extra, Register, Doc and HTML
 *    name arrays.
 * 2. Character contains the ChrFmt and HTMLChrFmt name arrays.
 * 3. Page contains the PageDesc name array.
 * 4. Frame contains the FrmFmt name array.
 * 5. Numbering Rule contains the NumRule name array.
 */

/*
 * There is a further complication that came to light later. If someone enters
 * a user-defined style name which is the same as a programmatic name, this
 * name clash must be handled.
 *
 * Therefore, when there is a danger of a nameclash, the boolean bDisambiguate
 * must be set to true in the SwStyleNameMapper call (it defaults to false).
 * This will cause the following to happen:
 *
 * If the UI style name either equals a programmatic name or already ends
 * with " (user)", then it must append " (user)" to the end.
 *
 * When a programmatic name is being converted to a UI name, if it ends in
 * " (user)", we simply remove it.
 */

class SvStringsDtor;
class String;
struct SwTableEntry;

typedef ::std::hash_map < const String*, sal_uInt16, StringHash, StringEq > NameToIdHash;

class SwStyleNameMapper
{
    friend void _InitCore();
    friend void _FinitCore();

protected:
    // UI Name tables
    static SvStringsDtor    *pTextUINameArray,
                            *pListsUINameArray,
                            *pExtraUINameArray,
                            *pRegisterUINameArray,
                            *pDocUINameArray,
                            *pHTMLUINameArray,
                            *pFrmFmtUINameArray,
                            *pChrFmtUINameArray,
                            *pHTMLChrFmtUINameArray,
                            *pPageDescUINameArray,
                            *pNumRuleUINameArray,
    // Programmatic Name tables
                            *pTextProgNameArray,
                            *pListsProgNameArray,
                            *pExtraProgNameArray,
                            *pRegisterProgNameArray,
                            *pDocProgNameArray,
                            *pHTMLProgNameArray,
                            *pFrmFmtProgNameArray,
                            *pChrFmtProgNameArray,
                            *pHTMLChrFmtProgNameArray,
                            *pPageDescProgNameArray,
                            *pNumRuleProgNameArray;

    static NameToIdHash     *pParaUIMap,
                            *pCharUIMap,
                            *pPageUIMap,
                            *pFrameUIMap,
                            *pNumRuleUIMap,

                            *pParaProgMap,
                            *pCharProgMap,
                            *pPageProgMap,
                            *pFrameProgMap,
                            *pNumRuleProgMap;

    static SvStringsDtor* NewUINameArray( SvStringsDtor*&,
                                      sal_uInt16 nStt,
                                      sal_uInt16 nEnd );

    static SvStringsDtor* NewProgNameArray( SvStringsDtor*&,
                                          const SwTableEntry *pTable,
                                          sal_uInt8 nCount);

    static void fillNameFromId ( sal_uInt16 nId, String &rName, sal_Bool bProgName );
    static const String& getNameFromId ( sal_uInt16 nId, const String &rName, sal_Bool bProgName );
    static const NameToIdHash& getHashTable ( SwGetPoolIdFromName, sal_Bool bProgName );
    static sal_Bool SuffixIsUser ( const String & rString );
    static void CheckSuffixAndDelete ( String & rString );

public:
    // This gets the UI Name from the programmatic name
    static const String& GetUIName ( const String& rName, SwGetPoolIdFromName );
    static         void FillUIName ( const String& rName, String& rFillName, SwGetPoolIdFromName, sal_Bool bDisambiguate = sal_False );

    // Get the programmatic Name from the UI name
    static const String& GetProgName ( const String& rName, SwGetPoolIdFromName );
    static         void FillProgName ( const String& rName, String& rFillName, SwGetPoolIdFromName, sal_Bool bDisambiguate = sal_False );

    // This gets the UI Name from the Pool ID
    SW_DLLPUBLIC static          void FillUIName ( sal_uInt16 nId, String& rFillName );
    SW_DLLPUBLIC static const String& GetUIName  ( sal_uInt16 nId, const String& rName );

    // This gets the programmatic Name from the Pool ID
    static          void FillProgName( sal_uInt16 nId, String& rFillName );
    static const String& GetProgName ( sal_uInt16 nId, const String& rName );

    // This gets the PoolId from the UI Name
    SW_DLLPUBLIC static sal_uInt16 GetPoolIdFromUIName( const String& rName, SwGetPoolIdFromName );

    // Get the Pool ID from the programmatic name
    static sal_uInt16 GetPoolIdFromProgName( const String& rName, SwGetPoolIdFromName );

    // used to convert the 4 special ExtraProg/UINames for
    // RES_POOLCOLL_LABEL_DRAWING,  RES_POOLCOLL_LABEL_ABB,
    // RES_POOLCOLL_LABEL_TABLE, RES_POOLCOLL_LABEL_FRAME
    // forth and back.
    // Non-matching names remain unchanged.
    SW_DLLPUBLIC static const String GetSpecialExtraProgName( const String& rExtraUIName );
    static const String GetSpecialExtraUIName( const String& rExtraProgName );

    static const SvStringsDtor& GetTextUINameArray();
    static const SvStringsDtor& GetListsUINameArray();
    static const SvStringsDtor& GetExtraUINameArray();
    static const SvStringsDtor& GetRegisterUINameArray();
    static const SvStringsDtor& GetDocUINameArray();
    static const SvStringsDtor& GetHTMLUINameArray();
    static const SvStringsDtor& GetFrmFmtUINameArray();
    static const SvStringsDtor& GetChrFmtUINameArray();
    static const SvStringsDtor& GetHTMLChrFmtUINameArray();
    static const SvStringsDtor& GetPageDescUINameArray();
    static const SvStringsDtor& GetNumRuleUINameArray();

    static const SvStringsDtor& GetTextProgNameArray();
    static const SvStringsDtor& GetListsProgNameArray();
    static const SvStringsDtor& GetExtraProgNameArray();
    static const SvStringsDtor& GetRegisterProgNameArray();
    static const SvStringsDtor& GetDocProgNameArray();
    static const SvStringsDtor& GetHTMLProgNameArray();
    static const SvStringsDtor& GetFrmFmtProgNameArray();
    static const SvStringsDtor& GetChrFmtProgNameArray();
    static const SvStringsDtor& GetHTMLChrFmtProgNameArray();
    static const SvStringsDtor& GetPageDescProgNameArray();
    static const SvStringsDtor& GetNumRuleProgNameArray();
};
#endif // _NAME_MAPPER_HXX
<|endoftext|>


<commit_before>#include "stdafx.h"
#include "error.h"
#include "utils.h"

const wstr msg_table[] = {
	L"Could't open the file \"%1%\".",
	L"Couldn't open the directory \"%1%\".",
	L"Couldn't create the file \"%1%\".",
	L"Couldn't create the directory \"%1%\".",
	L"Couldn't delete the file \"%1%\".",
	L"Couldn't delete the directory \"%1%\".",
	L"Couldn't get contents of the directory \"%1%\".",
	L"Couldn't get information of the file \"%1%\".",
	L"Couldn't get extended attributes of the file or directory \"%1%\".",
	L"Couldn't set extended attributes of the file or directory \"%1%\".",
	L"Couldn't set the case sensitive attribute of the directory \"%1%\".",
	L"Couldn't create the hard link from \"%1%\" to \"%2%\".",
	L"Couldn't read from the file \"%1%\".",
	L"Couldn't write to the file \"%1%\".",
	L"Couldn't recognize the path \"%1%\".",
	L"Couldn't convert a string from UTF-8 encoding to wide chars.",
	L"Error occurred while processing the archive.",
	L"Couldn't get Windows version information. \"%1%\"",
	L"Windows 10 v%1% (v10.0.%2%) or later is required. Please upgrade your system.",
	L"Couldn't open or create the registry key \"%1%\".",
	L"Couldn't delete the registry key \"%1%\".",
	L"Couldn't get subkeys of the registry key \"%1%\".",
	L"Couldn't copy the registry key \"%1%\" to \"%2%\".",
	L"Couldn't get the value \"%2%\" of the registry key \"%1%\".",
	L"Couldn't set the value \"%2%\" of the registry key \"%1%\".",
	L"Couldn't create a GUID.",
	L"Couldn't convert a GUID to a string.",
	L"Couldn't find the distro named \"%1%\".",
	L"A distro named \"%1%\" already exists.",
	L"No action is specified.",
	L"The action \"%1%\" is not recognized.",
	L"Couldn't load wslapi.dll. Please make sure that WSL has been installed.",
	L"Error occurred when trying to launch the distro \"%1%\".",
	L"Error occurred when creating a shortcut."
};

err error_hresult(err_msg msg_code, const std::vector<wstr> &msg_args, HRESULT err_code) {
	return err{ msg_code,msg_args,err_code };
}

err error_win32(err_msg msg_code, const std::vector<wstr> &msg_args, uint32_t err_code) {
	return error_hresult(msg_code, msg_args, HRESULT_FROM_WIN32(err_code));
}

err error_win32_last(err_msg msg_code, const std::vector<wstr> &msg_args) {
	return error_win32(msg_code, msg_args, GetLastError());
}

err error_nt(err_msg msg_code, const std::vector<wstr> &msg_args, NTSTATUS err_code) {
	return error_hresult(msg_code, msg_args, HRESULT_FROM_NT(err_code));
}

err error_other(err_msg msg_code, const std::vector<wstr> &msg_args) {
	return error_hresult(msg_code, msg_args, S_OK);
}

wstr err::format() const {
	std::wstringstream ss;

	auto fmt = boost::wformat(msg_table[msg_code]);
	for (const auto &s : msg_args) fmt = fmt % s;
	ss << fmt << std::endl;

	if (err_code) {
		ss << L"Reason: ";
		if (err_code & FACILITY_NT_BIT) {
			auto stat = err_code & ~FACILITY_NT_BIT;
			wchar_t *buf = nullptr;
			auto f = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS;
			auto hm = LoadLibrary(L"ntdll.dll");
			auto ok = hm && FormatMessage(f, hm, stat, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (wchar_t *)&buf, 0, nullptr);
			if (hm) FreeLibrary(hm);
			if (ok) {
				ss << buf;
				LocalFree(buf);
			} else {
				ss << L"Unknown NTSTATUS: " << L"0x" << std::setfill(L'0') << std::setw(8) << std::hex << stat;
			}
		} else {
			_com_error ce(err_code);
			ss << ce.ErrorMessage();
		}
	}

	return ss.str();
}

void err::push_if_empty(crwstr arg) {
	if (msg_args.empty()) msg_args.push_back(arg);
}
<commit_msg>fix typo Could't Couldn't<commit_after>#include "stdafx.h"
#include "error.h"
#include "utils.h"

const wstr msg_table[] = {
	L"Couldn't open the file \"%1%\".",
	L"Couldn't open the directory \"%1%\".",
	L"Couldn't create the file \"%1%\".",
	L"Couldn't create the directory \"%1%\".",
	L"Couldn't delete the file \"%1%\".",
	L"Couldn't delete the directory \"%1%\".",
	L"Couldn't get contents of the directory \"%1%\".",
	L"Couldn't get information of the file \"%1%\".",
	L"Couldn't get extended attributes of the file or directory \"%1%\".",
	L"Couldn't set extended attributes of the file or directory \"%1%\".",
	L"Couldn't set the case sensitive attribute of the directory \"%1%\".",
	L"Couldn't create the hard link from \"%1%\" to \"%2%\".",
	L"Couldn't read from the file \"%1%\".",
	L"Couldn't write to the file \"%1%\".",
	L"Couldn't recognize the path \"%1%\".",
	L"Couldn't convert a string from UTF-8 encoding to wide chars.",
	L"Error occurred while processing the archive.",
	L"Couldn't get Windows version information. \"%1%\"",
	L"Windows 10 v%1% (v10.0.%2%) or later is required. Please upgrade your system.",
	L"Couldn't open or create the registry key \"%1%\".",
	L"Couldn't delete the registry key \"%1%\".",
	L"Couldn't get subkeys of the registry key \"%1%\".",
	L"Couldn't copy the registry key \"%1%\" to \"%2%\".",
	L"Couldn't get the value \"%2%\" of the registry key \"%1%\".",
	L"Couldn't set the value \"%2%\" of the registry key \"%1%\".",
	L"Couldn't create a GUID.",
	L"Couldn't convert a GUID to a string.",
	L"Couldn't find the distro named \"%1%\".",
	L"A distro named \"%1%\" already exists.",
	L"No action is specified.",
	L"The action \"%1%\" is not recognized.",
	L"Couldn't load wslapi.dll. Please make sure that WSL has been installed.",
	L"Error occurred when trying to launch the distro \"%1%\".",
	L"Error occurred when creating a shortcut."
};

err error_hresult(err_msg msg_code, const std::vector<wstr> &msg_args, HRESULT err_code) {
	return err{ msg_code,msg_args,err_code };
}

err error_win32(err_msg msg_code, const std::vector<wstr> &msg_args, uint32_t err_code) {
	return error_hresult(msg_code, msg_args, HRESULT_FROM_WIN32(err_code));
}

err error_win32_last(err_msg msg_code, const std::vector<wstr> &msg_args) {
	return error_win32(msg_code, msg_args, GetLastError());
}

err error_nt(err_msg msg_code, const std::vector<wstr> &msg_args, NTSTATUS err_code) {
	return error_hresult(msg_code, msg_args, HRESULT_FROM_NT(err_code));
}

err error_other(err_msg msg_code, const std::vector<wstr> &msg_args) {
	return error_hresult(msg_code, msg_args, S_OK);
}

wstr err::format() const {
	std::wstringstream ss;

	auto fmt = boost::wformat(msg_table[msg_code]);
	for (const auto &s : msg_args) fmt = fmt % s;
	ss << fmt << std::endl;

	if (err_code) {
		ss << L"Reason: ";
		if (err_code & FACILITY_NT_BIT) {
			auto stat = err_code & ~FACILITY_NT_BIT;
			wchar_t *buf = nullptr;
			auto f = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS;
			auto hm = LoadLibrary(L"ntdll.dll");
			auto ok = hm && FormatMessage(f, hm, stat, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (wchar_t *)&buf, 0, nullptr);
			if (hm) FreeLibrary(hm);
			if (ok) {
				ss << buf;
				LocalFree(buf);
			} else {
				ss << L"Unknown NTSTATUS: " << L"0x" << std::setfill(L'0') << std::setw(8) << std::hex << stat;
			}
		} else {
			_com_error ce(err_code);
			ss << ce.ErrorMessage();
		}
	}

	return ss.str();
}

void err::push_if_empty(crwstr arg) {
	if (msg_args.empty()) msg_args.push_back(arg);
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: actctrl.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: obo $ $Date: 2004-11-16 17:00:00 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _ACTCTRL_HXX
#define _ACTCTRL_HXX

#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

/*--------------------------------------------------------------------
    Beschreibung:   numerische Eingabe
 --------------------------------------------------------------------*/

class SW_DLLPUBLIC NumEditAction: public NumericField
{
    Link aActionLink;

protected:
    virtual void Action();
    virtual long    Notify( NotifyEvent& rNEvt );
public:
    NumEditAction( Window* pParent, const ResId& rResId ) :
                                NumericField(pParent, rResId) {}

    void        SetActionHdl( const Link& rLink )   { aActionLink = rLink;}
    const Link& GetActionHdl() const                { return aActionLink; }
};

/* -----------------21.04.98 08:11-------------------
 * Edit, dass keine Spaces akzeptiert
 * --------------------------------------------------*/
class SW_DLLPUBLIC NoSpaceEdit : public Edit
{
    String sForbiddenChars;
protected:
    virtual void KeyInput( const KeyEvent& );
    virtual void        Modify();

public:
    NoSpaceEdit( Window* pParent, const ResId& rResId)
        : Edit(pParent, rResId),
        sForbiddenChars(String::CreateFromAscii(" "))
    {}
    void            SetForbiddenChars(const String& rSet){sForbiddenChars = rSet;}
    const String&   GetForbiddenChars(){return sForbiddenChars;}
};

/* -----------------21.04.98 08:33-------------------
 * Kein Space und kein Punkt
 * --------------------------------------------------*/
class TableNameEdit : public NoSpaceEdit
{
public:
    TableNameEdit(Window* pWin, const ResId& rResId) :
                            NoSpaceEdit(pWin, rResId)
                                {SetForbiddenChars(String::CreateFromAscii(" .<>"));}
};
/* -----------------25.06.2003 15:55-----------------
    call a link when KEY_RETURN is pressed
 --------------------------------------------------*/
class SW_DLLPUBLIC ReturnActionEdit : public Edit
{
    Link    aReturnActionLink;
public:
    ReturnActionEdit( Window* pParent, const ResId& rResId)
        : Edit(pParent, rResId){}
    ~ReturnActionEdit();
    virtual void KeyInput( const KeyEvent& );

    void SetReturnActionLink(const Link& rLink)
            { aReturnActionLink = rLink;}
};

#endif
<commit_msg>INTEGRATION: CWS ooo19126 (1.6.460); FILE MERGED 2005/09/05 13:44:55 rt 1.6.460.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: actctrl.hxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 08:58:09 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _ACTCTRL_HXX
#define _ACTCTRL_HXX

#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

/*--------------------------------------------------------------------
    Beschreibung:   numerische Eingabe
 --------------------------------------------------------------------*/

class SW_DLLPUBLIC NumEditAction: public NumericField
{
    Link aActionLink;

protected:
    virtual void Action();
    virtual long    Notify( NotifyEvent& rNEvt );
public:
    NumEditAction( Window* pParent, const ResId& rResId ) :
                                NumericField(pParent, rResId) {}

    void        SetActionHdl( const Link& rLink )   { aActionLink = rLink;}
    const Link& GetActionHdl() const                { return aActionLink; }
};

/* -----------------21.04.98 08:11-------------------
 * Edit, dass keine Spaces akzeptiert
 * --------------------------------------------------*/
class SW_DLLPUBLIC NoSpaceEdit : public Edit
{
    String sForbiddenChars;
protected:
    virtual void KeyInput( const KeyEvent& );
    virtual void        Modify();

public:
    NoSpaceEdit( Window* pParent, const ResId& rResId)
        : Edit(pParent, rResId),
        sForbiddenChars(String::CreateFromAscii(" "))
    {}
    void            SetForbiddenChars(const String& rSet){sForbiddenChars = rSet;}
    const String&   GetForbiddenChars(){return sForbiddenChars;}
};

/* -----------------21.04.98 08:33-------------------
 * Kein Space und kein Punkt
 * --------------------------------------------------*/
class TableNameEdit : public NoSpaceEdit
{
public:
    TableNameEdit(Window* pWin, const ResId& rResId) :
                            NoSpaceEdit(pWin, rResId)
                                {SetForbiddenChars(String::CreateFromAscii(" .<>"));}
};
/* -----------------25.06.2003 15:55-----------------
    call a link when KEY_RETURN is pressed
 --------------------------------------------------*/
class SW_DLLPUBLIC ReturnActionEdit : public Edit
{
    Link    aReturnActionLink;
public:
    ReturnActionEdit( Window* pParent, const ResId& rResId)
        : Edit(pParent, rResId){}
    ~ReturnActionEdit();
    virtual void KeyInput( const KeyEvent& );

    void SetReturnActionLink(const Link& rLink)
            { aReturnActionLink = rLink;}
};

#endif
<|endoftext|>


<commit_before>// Check compiling a module interface to a .pcm file.
//
// RUN: %clang -fmodules-ts -x c++-module --precompile %s -Dimplementation= -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE
//
// CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface
// CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
// CHECK-PRECOMPILE-SAME: -x c++-module
// CHECK-PRECOMPILE-SAME: modules-ts.cpp

// Check compiling a .pcm file to a .o file.
//
// RUN: %clang -fmodules-ts %t.pcm -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-COMPILE
//
// CHECK-COMPILE: -cc1 {{.*}} -emit-obj
// CHECK-COMPILE-SAME: -o {{.*}}.pcm.o
// CHECK-COMPILE-SAME: -x pcm
// CHECK-COMPILE-SAME: {{.*}}.pcm

// Check use of a .pcm file in another compilation.
//
// RUN: %clang -fmodules-ts -fmodule-file=%t.pcm %s -c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
//
// CHECK-USE: -cc1
// CHECK-USE-SAME: -emit-obj
// CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
// CHECK-USE-SAME: -o {{.*}}.o {{.*}}-x c++
// CHECK-USE-SAME: modules-ts.cpp

// Check combining precompile and compile steps works.
//
// RUN: %clang -fmodules-ts -x c++-module %s -Dimplementation= -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE --check-prefix=CHECK-COMPILE

// Check that .cppm is treated as a module implicitly.
// RUN: cp %s %t.cppm
// RUN: %clang -fmodules-ts --precompile %t.cppm -Dimplementation= -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE

// Note, we use -Dimplementation= to make this a valid module interface unit when building the interface.
module implementation foo;
<commit_msg>clang/test/Driver/modules-ts.cpp: Satisfy quoted filename.<commit_after>// Check compiling a module interface to a .pcm file.
//
// RUN: %clang -fmodules-ts -x c++-module --precompile %s -Dimplementation= -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE
//
// CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface
// CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
// CHECK-PRECOMPILE-SAME: -x c++-module
// CHECK-PRECOMPILE-SAME: modules-ts.cpp

// Check compiling a .pcm file to a .o file.
//
// RUN: %clang -fmodules-ts %t.pcm -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-COMPILE
//
// CHECK-COMPILE: -cc1 {{.*}} -emit-obj
// CHECK-COMPILE-SAME: -o {{.*}}.pcm.o
// CHECK-COMPILE-SAME: -x pcm
// CHECK-COMPILE-SAME: {{.*}}.pcm

// Check use of a .pcm file in another compilation.
//
// RUN: %clang -fmodules-ts -fmodule-file=%t.pcm %s -c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
//
// CHECK-USE: -cc1
// CHECK-USE-SAME: -emit-obj
// CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
// CHECK-USE-SAME: -o {{.*}}.o{{"?}} {{.*}}-x c++
// CHECK-USE-SAME: modules-ts.cpp

// Check combining precompile and compile steps works.
//
// RUN: %clang -fmodules-ts -x c++-module %s -Dimplementation= -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE --check-prefix=CHECK-COMPILE

// Check that .cppm is treated as a module implicitly.
// RUN: cp %s %t.cppm
// RUN: %clang -fmodules-ts --precompile %t.cppm -Dimplementation= -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE

// Note, we use -Dimplementation= to make this a valid module interface unit when building the interface.
module implementation foo;
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: glosdoc.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: vg $ $Date: 2003-04-01 15:40:57 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _GLOSDOC_HXX
#define _GLOSDOC_HXX

#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif

#ifndef _SVARRAY_HXX //autogen
#include <svtools/svarray.hxx>
#endif
#ifndef _COM_SUN_STAR_TEXT_XAUTOTEXTGROUP_HPP_
#include <com/sun/star/text/XAutoTextGroup.hpp>
#endif

class SwTextBlocks;
class SvStrings;
class SwDocShell;

#ifndef SW_DECL_SWDOCSHELL_DEFINED
#define SW_DECL_SWDOCSHELL_DEFINED
#ifndef _REF_HXX
#include <tools/ref.hxx>
#endif
SV_DECL_REF( SwDocShell )
#endif

#ifndef _CPPUHELPER_WEAKREF_HXX_
#include <cppuhelper/weakref.hxx>
#endif

#include <vector>

typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextGroup > AutoTextGroupRef;
typedef ::std::vector< AutoTextGroupRef > UnoAutoTextGroups;

typedef ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry > AutoTextEntryRef;
typedef ::std::vector< AutoTextEntryRef > UnoAutoTextEntries;

#define GLOS_DELIM (sal_Unicode)'*'

// CLASS -----------------------------------------------------------------
class SwGlossaries
{
    UnoAutoTextGroups       aGlossaryGroups;
    UnoAutoTextEntries      aGlossaryEntries;
    String                  aPath;
    String                  sOldErrPath;
    String                  sErrPath;
    SvStrings               *pPathArr;
    SvStrings               *pGlosArr;
    BOOL                    bError;

    SwTextBlocks*   GetGlosDoc(const String &rName, BOOL bCreate = TRUE) const;
    SvStrings       *GetNameList();
    // implementation in unoatxt.cxx
    void RemoveFileFromList( const String& rGroup );
    void InvalidateUNOOjects();

public:
    SwGlossaries();
    ~SwGlossaries();

    /** returns the cached AutoTextGroup (if any) for the given group name

        @precond
            If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.

        @param _rGroupName
            the name of the glossaries group
        @param _bCreate
            if <TRUE/>, the group is created if it does not yet exist
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup >
                            GetAutoTextGroup(
                                const ::rtl::OUString& _rGroupName,
                                bool _bCreate = false
                            );

    /** returns the cached AutoTextEntry (if any) for the given group/with the given name

        @precond
            If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.

        @param _rGroupAccessName
            the name to access the group
        @param _rGroupName
            the name of the glossaries group, as to be passed to the entry
        @param _rEntryName
            the name of the auto text entry
        @param _bCreate
            if <TRUE/>, the entry is created if it does not yet exist
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry >
                            GetAutoTextEntry(
                                const String& _rCompleteGroupName,
                                const ::rtl::OUString& _rGroupName,
                                const ::rtl::OUString& _rEntryName,
                                bool _bCreate = false
                            );

    USHORT                  GetGroupCnt();
    String                  GetGroupName(USHORT );
    String                  GetGroupTitle( const String& rGroupName );

    BOOL            FindGroupName(String & rGroup);

    SwTextBlocks*   GetGroupDoc(const String &rName,
                                BOOL bCreate = FALSE) const;
    SwTextBlocks*   GetDefGroupDoc() const {return GetGroupDoc(GetDefName());}
    void            PutGroupDoc(SwTextBlocks *pBlock);
    static String   GetDefName();
    static String   GetExtension();

    BOOL            NewGroupDoc(String &rGroupName, const String& rTitle);
    BOOL            RenameGroupDoc(const String& sOldGroup, String& sNewGroup, const String& rNewTitle);
    BOOL            DelGroupDoc(const String &);
    SwDocShellRef   EditGroupDoc(const String &rGrpName, const String& rShortName, BOOL bShow = TRUE );
    void            SaveGroupDoc(const String &rGrpName, const String& rLongName );
    void            UpdateGlosPath(BOOL bFull);
    void            ShowError();
    inline ULONG    IsGlosPathErr() { return bError; }
    const SvStrings*    GetPathArray() const {return pPathArr;}
};

#endif // _GLOSDOC_HXX
<commit_msg>INTEGRATION: CWS tune03 (1.5.598); FILE MERGED 2004/07/19 19:11:27 mhu 1.5.598.1: #i29979# Added SW_DLLPUBLIC/PRIVATE (see swdllapi.h) to exported symbols/classes.<commit_after>/*************************************************************************
 *
 *  $RCSfile: glosdoc.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 08:59:15 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _GLOSDOC_HXX
#define _GLOSDOC_HXX

#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif
#ifndef _SVARRAY_HXX //autogen
#include <svtools/svarray.hxx>
#endif

#ifndef _COM_SUN_STAR_TEXT_XAUTOTEXTGROUP_HPP_
#include <com/sun/star/text/XAutoTextGroup.hpp>
#endif

class SwTextBlocks;
class SvStrings;
class SwDocShell;

#ifndef SW_DECL_SWDOCSHELL_DEFINED
#define SW_DECL_SWDOCSHELL_DEFINED
#ifndef _REF_HXX
#include <tools/ref.hxx>
#endif
SV_DECL_REF( SwDocShell )
#endif

#ifndef _CPPUHELPER_WEAKREF_HXX_
#include <cppuhelper/weakref.hxx>
#endif

#ifndef INCLUDED_VECTOR
#include <vector>
#define INCLUDED_VECTOR
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XAutoTextGroup > AutoTextGroupRef;
typedef ::std::vector< AutoTextGroupRef > UnoAutoTextGroups;

typedef ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry > AutoTextEntryRef;
typedef ::std::vector< AutoTextEntryRef > UnoAutoTextEntries;

#define GLOS_DELIM (sal_Unicode)'*'

// CLASS -----------------------------------------------------------------
class SW_DLLPUBLIC SwGlossaries
{
    UnoAutoTextGroups       aGlossaryGroups;
    UnoAutoTextEntries      aGlossaryEntries;
    String                  aPath;
    String                  sOldErrPath;
    String                  sErrPath;
    SvStrings               *pPathArr;
    SvStrings               *pGlosArr;
    BOOL                    bError;

    SW_DLLPRIVATE SwTextBlocks* GetGlosDoc(const String &rName, BOOL bCreate = TRUE) const;
    SW_DLLPRIVATE SvStrings     *GetNameList();

    // implementation in unoatxt.cxx
    SW_DLLPRIVATE void RemoveFileFromList( const String& rGroup );
    SW_DLLPRIVATE void InvalidateUNOOjects();

public:
    SwGlossaries();
    ~SwGlossaries();

    /** returns the cached AutoTextGroup (if any) for the given group name

        @precond
            If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.

        @param _rGroupName
            the name of the glossaries group
        @param _bCreate
            if <TRUE/>, the group is created if it does not yet exist
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextGroup >
                            GetAutoTextGroup(
                                const ::rtl::OUString& _rGroupName,
                                bool _bCreate = false
                            );

    /** returns the cached AutoTextEntry (if any) for the given group/with the given name

        @precond
            If <arg>_bCreate</arg> is <TRUE/>, the SolarMutex must be locked when calling into this method.

        @param _rGroupAccessName
            the name to access the group
        @param _rGroupName
            the name of the glossaries group, as to be passed to the entry
        @param _rEntryName
            the name of the auto text entry
        @param _bCreate
            if <TRUE/>, the entry is created if it does not yet exist
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextEntry >
                            GetAutoTextEntry(
                                const String& _rCompleteGroupName,
                                const ::rtl::OUString& _rGroupName,
                                const ::rtl::OUString& _rEntryName,
                                bool _bCreate = false
                            );

    USHORT                  GetGroupCnt();
    String                  GetGroupName(USHORT );
    String                  GetGroupTitle( const String& rGroupName );

    BOOL            FindGroupName(String & rGroup);

    SwTextBlocks*   GetGroupDoc(const String &rName,
                                BOOL bCreate = FALSE) const;
    SwTextBlocks*   GetDefGroupDoc() const {return GetGroupDoc(GetDefName());}
    void            PutGroupDoc(SwTextBlocks *pBlock);
    static String   GetDefName();
    static String   GetExtension();

    BOOL            NewGroupDoc(String &rGroupName, const String& rTitle);
    BOOL            RenameGroupDoc(const String& sOldGroup, String& sNewGroup, const String& rNewTitle);
    BOOL            DelGroupDoc(const String &);
    SwDocShellRef   EditGroupDoc(const String &rGrpName, const String& rShortName, BOOL bShow = TRUE );
    void            SaveGroupDoc(const String &rGrpName, const String& rLongName );
    void            UpdateGlosPath(BOOL bFull);
    void            ShowError();
    inline ULONG    IsGlosPathErr() { return bError; }
    const SvStrings*    GetPathArray() const {return pPathArr;}
};

#endif // _GLOSDOC_HXX
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: outline.hxx,v $
 *
 *  $Revision: 1.9 $
 *
 *  last change: $Author: vg $ $Date: 2007-10-22 15:21:26 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _OUTLINE_HXX
#define _OUTLINE_HXX

#ifndef _SFXTABDLG_HXX //autogen
#include <sfx2/tabdlg.hxx>
#endif

#ifndef _SV_MENU_HXX //autogen
#include <vcl/menu.hxx>
#endif

#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif

#ifndef _STDCTRL_HXX //autogen
#include <svtools/stdctrl.hxx>
#endif

#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif

#ifndef _LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif

#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif

#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif

#include "swtypes.hxx"      //fuer MAXLEVEL
#ifndef _NUMPREVW_HXX
#include <numprevw.hxx>
#endif
#ifndef _NUMBERINGTYPELISTBOX_HXX
#include <numberingtypelistbox.hxx>
#endif

class SwWrtShell;
class SwNumRule;
class SwChapterNumRules;

/* -----------------07.07.98 13:38-------------------
 *
 * --------------------------------------------------*/
class SwOutlineTabDialog : public SfxTabDialog
{
    static     USHORT    nNumLevel;

    String              aNullStr;
    String              aCollNames[MAXLEVEL];
    PopupMenu           aFormMenu;

    SwWrtShell&         rWrtSh;
    SwNumRule*          pNumRule;
    SwChapterNumRules*  pChapterNumRules;

    BOOL                bModified : 1;

    protected:
    DECL_LINK( CancelHdl, Button * );
    DECL_LINK( FormHdl, Button * );
    DECL_LINK( MenuSelectHdl, Menu * );

        virtual void    PageCreated(USHORT nPageId, SfxTabPage& rPage);
        virtual short   Ok();

    public:
        SwOutlineTabDialog(Window* pParent,
                    const SfxItemSet* pSwItemSet,
                    SwWrtShell &);
        ~SwOutlineTabDialog();

    SwNumRule*          GetNumRule() {return pNumRule;}
    USHORT              GetLevel(const String &rFmtName) const;
    String*             GetCollNames() {return aCollNames;}

    static USHORT       GetActNumLevel() {return nNumLevel;}
    static void         SetActNumLevel(USHORT nSet) {nNumLevel = nSet;}
};
/* -----------------07.07.98 13:47-------------------
 *
 * --------------------------------------------------*/
class SwOutlineSettingsTabPage : public SfxTabPage
{
    ListBox         aLevelLB;
    FixedLine       aLevelFL;

    FixedText       aCollLbl;
    ListBox         aCollBox;
    FixedText       aNumberLbl;
    SwNumberingTypeListBox  aNumberBox;
    FixedText       aCharFmtFT;
    ListBox         aCharFmtLB;
    FixedText       aAllLevelFT;
    NumericField    aAllLevelNF;
    FixedText       aDelim;
    FixedText       aPrefixFT;
    Edit            aPrefixED;
    FixedText       aSuffixFT;
    Edit            aSuffixED;
    FixedText       aStartLbl;
    NumericField    aStartEdit;
    FixedLine        aNumberFL;
    NumberingPreview aPreviewWIN;

    String              aNoFmtName;
    String              aSaveCollNames[MAXLEVEL];
    SwWrtShell*         pSh;
    SwNumRule*          pNumRule;
    String*             pCollNames;
    USHORT              nActLevel;

    DECL_LINK( LevelHdl, ListBox * );
    DECL_LINK( ToggleComplete, NumericField * );
    DECL_LINK( CollSelect, ListBox * );
    DECL_LINK( CollSelectGetFocus, ListBox * );
    DECL_LINK( NumberSelect, SwNumberingTypeListBox * );
    DECL_LINK( DelimModify, Edit * );
    DECL_LINK( StartModified, NumericField * );
    DECL_LINK( CharFmtHdl, ListBox * );

    void    Update();

    void    SetModified(){aPreviewWIN.Invalidate();}
    void    CheckForStartValue_Impl(sal_uInt16 nNumberingType);

    using TabPage::ActivatePage;
    using TabPage::DeactivatePage;

public:
    SwOutlineSettingsTabPage(Window* pParent, const SfxItemSet& rSet);
    ~SwOutlineSettingsTabPage();

    void SetWrtShell(SwWrtShell* pShell);

    virtual void        ActivatePage(const SfxItemSet& rSet);
    virtual int         DeactivatePage(SfxItemSet *pSet);

    virtual BOOL        FillItemSet( SfxItemSet& rSet );
    virtual void        Reset( const SfxItemSet& rSet );
    static SfxTabPage*  Create( Window* pParent,
                                const SfxItemSet& rAttrSet);
};
#endif
<commit_msg>INTEGRATION: CWS changefileheader (1.9.216); FILE MERGED 2008/04/01 15:59:18 thb 1.9.216.3: #i85898# Stripping all external header guards 2008/04/01 12:55:30 thb 1.9.216.2: #i85898# Stripping all external header guards 2008/03/31 16:58:37 rt 1.9.216.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: outline.hxx,v $
 * $Revision: 1.10 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _OUTLINE_HXX
#define _OUTLINE_HXX

#include <sfx2/tabdlg.hxx>

#include <vcl/menu.hxx>

#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#include <svtools/stdctrl.hxx>

#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif

#ifndef _LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif

#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif

#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif

#include "swtypes.hxx"      //fuer MAXLEVEL
#include <numprevw.hxx>
#include <numberingtypelistbox.hxx>

class SwWrtShell;
class SwNumRule;
class SwChapterNumRules;

/* -----------------07.07.98 13:38-------------------
 *
 * --------------------------------------------------*/
class SwOutlineTabDialog : public SfxTabDialog
{
    static     USHORT    nNumLevel;

    String              aNullStr;
    String              aCollNames[MAXLEVEL];
    PopupMenu           aFormMenu;

    SwWrtShell&         rWrtSh;
    SwNumRule*          pNumRule;
    SwChapterNumRules*  pChapterNumRules;

    BOOL                bModified : 1;

    protected:
    DECL_LINK( CancelHdl, Button * );
    DECL_LINK( FormHdl, Button * );
    DECL_LINK( MenuSelectHdl, Menu * );

        virtual void    PageCreated(USHORT nPageId, SfxTabPage& rPage);
        virtual short   Ok();

    public:
        SwOutlineTabDialog(Window* pParent,
                    const SfxItemSet* pSwItemSet,
                    SwWrtShell &);
        ~SwOutlineTabDialog();

    SwNumRule*          GetNumRule() {return pNumRule;}
    USHORT              GetLevel(const String &rFmtName) const;
    String*             GetCollNames() {return aCollNames;}

    static USHORT       GetActNumLevel() {return nNumLevel;}
    static void         SetActNumLevel(USHORT nSet) {nNumLevel = nSet;}
};
/* -----------------07.07.98 13:47-------------------
 *
 * --------------------------------------------------*/
class SwOutlineSettingsTabPage : public SfxTabPage
{
    ListBox         aLevelLB;
    FixedLine       aLevelFL;

    FixedText       aCollLbl;
    ListBox         aCollBox;
    FixedText       aNumberLbl;
    SwNumberingTypeListBox  aNumberBox;
    FixedText       aCharFmtFT;
    ListBox         aCharFmtLB;
    FixedText       aAllLevelFT;
    NumericField    aAllLevelNF;
    FixedText       aDelim;
    FixedText       aPrefixFT;
    Edit            aPrefixED;
    FixedText       aSuffixFT;
    Edit            aSuffixED;
    FixedText       aStartLbl;
    NumericField    aStartEdit;
    FixedLine        aNumberFL;
    NumberingPreview aPreviewWIN;

    String              aNoFmtName;
    String              aSaveCollNames[MAXLEVEL];
    SwWrtShell*         pSh;
    SwNumRule*          pNumRule;
    String*             pCollNames;
    USHORT              nActLevel;

    DECL_LINK( LevelHdl, ListBox * );
    DECL_LINK( ToggleComplete, NumericField * );
    DECL_LINK( CollSelect, ListBox * );
    DECL_LINK( CollSelectGetFocus, ListBox * );
    DECL_LINK( NumberSelect, SwNumberingTypeListBox * );
    DECL_LINK( DelimModify, Edit * );
    DECL_LINK( StartModified, NumericField * );
    DECL_LINK( CharFmtHdl, ListBox * );

    void    Update();

    void    SetModified(){aPreviewWIN.Invalidate();}
    void    CheckForStartValue_Impl(sal_uInt16 nNumberingType);

    using TabPage::ActivatePage;
    using TabPage::DeactivatePage;

public:
    SwOutlineSettingsTabPage(Window* pParent, const SfxItemSet& rSet);
    ~SwOutlineSettingsTabPage();

    void SetWrtShell(SwWrtShell* pShell);

    virtual void        ActivatePage(const SfxItemSet& rSet);
    virtual int         DeactivatePage(SfxItemSet *pSet);

    virtual BOOL        FillItemSet( SfxItemSet& rSet );
    virtual void        Reset( const SfxItemSet& rSet );
    static SfxTabPage*  Create( Window* pParent,
                                const SfxItemSet& rAttrSet);
};
#endif
<|endoftext|>


<commit_before>/*********************************************************************
** Author: Zach Colbert
** Date: 22 September 2017
** Description: This program prints a message with your name in it.
*********************************************************************/

#include <iostream>
// using namespace std;

int main()
{
  std::cout << "Hi! It\'s me.\n";
  std::cout << "I\'m learning to program!\n";
  return 0;
}
<commit_msg>Reset the hello example to it's textbook form<commit_after>/*********************************************************************
** Author: Zach Colbert
** Date: 22 September 2017
** Description: This program prints a message with your name in it.
*********************************************************************/

#include <iostream>
using namespace std;

int main()
{
  cout << "Hi! It\'s me.\n";
  cout << "I\'m learning to program!\n";
  return 0;
}
<|endoftext|>


<commit_before><commit_msg>increase default ground affordance size from 10 to 15<commit_after><|endoftext|>


<commit_before>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/FORMAT/molFileFactory.h>
#include <BALL/FORMAT/genericMolFile.h>
#include <BALL/KERNEL/system.h>
#include <BALL/FORMAT/commandlineParser.h>

#include "version.h";

using namespace BALL;

int main(int argc, char* argv[])
{
	// instantiate CommandlineParser object
	CommandlineParser parpars("MolecularFileConverter", "converts molecular file-formats", VERSION, String(__DATE__), "File conversion");
	parpars.registerParameter("i",  "input file",    INFILE,  true);
	parpars.registerParameter("of", "output format", STRING,  false);
	parpars.registerParameter("o",  "output file",   OUTFILE, true);

	// the available formats
	String supp_formats = MolFileFactory::getSupportedFormats();

	// the manual
	String man = String("This tool converts different molecular file formats.\nSupported formats are ") + supp_formats + String(".");

	// we support: mol2, sdf, drf, pdb, ac, ent, brk, hin, mol, xyz,
	// mol2.gz, sdf.gz, drf.gz, pdb.gz, ac.gz, ent.gz, brk.gz, hin.gz, mol.gz, xyz.gz.
	parpars.setToolManual(man);

	parpars.setSupportedFormats("i", supp_formats);
	parpars.setSupportedFormats("o", supp_formats);

	// set supported formats as options for parameter of
	String formats = supp_formats;
	vector<String> temp;
	formats.split(temp,",");
	list<String> supp_format_list;
	for (Size i=0; i<temp.size(); i++)
	{
		supp_format_list.push_back(temp[i]);
	}
	parpars.setParameterRestrictions("of", supp_format_list);

	// parse the command line
	parpars.parse(argc, argv);

	// check if optional parameter 'of' is given
	String default_format = "mol2";
	if (parpars.has("of"))
		default_format = parpars.get("of");

	// read input/output file
	GenericMolFile* in_file  = MolFileFactory::open(parpars.get("i"), std::ios::in);
	GenericMolFile* out_file = MolFileFactory::open(parpars.get("o"), std::ios::out, default_format);

	if (!in_file)
	{
		// if file does not exist: complain and abort
		Log.error() << "error opening " << parpars.get("i") << " for input." << std::endl;
		return 2;
	}
	if (!out_file)
	{
		// if file does not exist: complain and abort
		Log.error() << "error opening " << parpars.get("o") << " for output." << std::endl;
		return 2;
	}

	// create a system and read the contents of the molecular file
	System S;
	in_file->read(S);
	in_file->close();

	// and write
	if (out_file)
	{
		out_file->write(S);
		out_file->close();
		Log.info() << "Wrote converted file " << parpars.get("o") << std::endl;
	}

	delete in_file;
	delete out_file;
}

<commit_msg>Fix typo in MolecularFileConverter<commit_after>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/FORMAT/molFileFactory.h>
#include <BALL/FORMAT/genericMolFile.h>
#include <BALL/KERNEL/system.h>
#include <BALL/FORMAT/commandlineParser.h>

#include "version.h"

using namespace BALL;

int main(int argc, char* argv[])
{
	// instantiate CommandlineParser object
	CommandlineParser parpars("MolecularFileConverter", "converts molecular file-formats", VERSION, String(__DATE__), "File conversion");
	parpars.registerParameter("i",  "input file",    INFILE,  true);
	parpars.registerParameter("of", "output format", STRING,  false);
	parpars.registerParameter("o",  "output file",   OUTFILE, true);

	// the available formats
	String supp_formats = MolFileFactory::getSupportedFormats();

	// the manual
	String man = String("This tool converts different molecular file formats.\nSupported formats are ") + supp_formats + String(".");

	// we support: mol2, sdf, drf, pdb, ac, ent, brk, hin, mol, xyz,
	// mol2.gz, sdf.gz, drf.gz, pdb.gz, ac.gz, ent.gz, brk.gz, hin.gz, mol.gz, xyz.gz.
	parpars.setToolManual(man);

	parpars.setSupportedFormats("i", supp_formats);
	parpars.setSupportedFormats("o", supp_formats);

	// set supported formats as options for parameter of
	String formats = supp_formats;
	vector<String> temp;
	formats.split(temp,",");
	list<String> supp_format_list;
	for (Size i=0; i<temp.size(); i++)
	{
		supp_format_list.push_back(temp[i]);
	}
	parpars.setParameterRestrictions("of", supp_format_list);

	// parse the command line
	parpars.parse(argc, argv);

	// check if optional parameter 'of' is given
	String default_format = "mol2";
	if (parpars.has("of"))
		default_format = parpars.get("of");

	// read input/output file
	GenericMolFile* in_file  = MolFileFactory::open(parpars.get("i"), std::ios::in);
	GenericMolFile* out_file = MolFileFactory::open(parpars.get("o"), std::ios::out, default_format);

	if (!in_file)
	{
		// if file does not exist: complain and abort
		Log.error() << "error opening " << parpars.get("i") << " for input." << std::endl;
		exit(2);
	}
	if (!out_file)
	{
		// if file does not exist: complain and abort
		Log.error() << "error opening " << parpars.get("o") << " for output." << std::endl;
		exit(2);
	}

	// create a system and read the contents of the molecular file
	System S;
	in_file->read(S);
	in_file->close();

	// and write
	if (out_file)
	{
		out_file->write(S);
		out_file->close();
		Log.info() << "Wrote converted file " << parpars.get("o") << std::endl;
	}

	delete in_file;
	delete out_file;
}

<|endoftext|>