<commit_before>/*****************************************************************************\
 *                        ANALYSIS PERFORMANCE TOOLS                         *
 *                               libparaver-api                              *
 *                      API Library for libparaver-kernel                    *
 *****************************************************************************
 *     ___     This library is free software; you can redistribute it and/or *
 *    /  __         modify it under the terms of the GNU LGPL as published   *
 *   /  /  _____    by the Free Software Foundation; either version 2.1      *
 *  /  /  /     \   of the License, or (at your option) any later version.   *
 * (  (  ( B S C )                                                           *
 *  \  \  \_____/   This library is distributed in 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 LGPL for more details.   *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public License  *
 * along with this library; if not, write to the Free Software Foundation,   *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA          *
 * The GNU LEsser General Public License is contained in the file COPYING.   *
 *                                 ---------                                 *
 *   Barcelona Supercomputing Center - Centro Nacional de Supercomputacion   *
\*****************************************************************************/

#include "workspace.h"

using std::string;
using std::vector;
using std::pair;

Workspace::Workspace()
{
}

Workspace::~Workspace()
{
}

string Workspace::getName() const
{
  return name;
}

WorkspaceValue::WorkspaceType Workspace::getType() const
{
  return myType;
}

vector<WorkspaceValue> Workspace::getAutoTypes() const
{
  return autoTypes;
}

vector<pair<string,string> > Workspace::getHintCFGs() const
{
  return hintCFGs;
}

pair<string,string> Workspace::getHintCFG( size_t whichHint ) const
{
  return hintCFGs[ whichHint ];
}

void Workspace::setName( string& whichName )
{
  name = whichName;
}

void Workspace::setType( WorkspaceValue::WorkspaceType whichType )
{
  myType = whichType;
  for( vector<WorkspaceValue>::iterator it = autoTypes.begin(); it != autoTypes.end(); ++it )
    it->myType = whichType;
}

void Workspace::setAutoTypes( vector<WorkspaceValue>& whichAutoTypes )
{
  autoTypes = whichAutoTypes;
}

void Workspace::addHintCFG( pair<string,string>& whichCFG )
{
  hintCFGs.push_back( whichCFG );
}

void Workspace::addHintCFG( size_t position, pair<string,string>& whichCFG )
{
  hintCFGs.insert( hintCFGs.begin() + position, whichCFG );
}

void Workspace::removeHintCFG( size_t whichHint )
{
  hintCFGs.erase( hintCFGs.begin() + whichHint );
}

void Workspace::modifyHintCFG( size_t position, pair<string,string>& whichCFG )
{
  hintCFGs[ position ] = whichCFG;
}

void Workspace::clearHintCFGs()
{
  hintCFGs.clear();
}


// load/save XML for import/export certain workspaces

void Workspace::loadXML( std::string &wsDir )
{
  // Read user defined
  std::ifstream ifs( wsDir );
  //ifs.open( wsDir );
  if( ifs.good() ) // due to xml_iarchive needs to be destroyed before fstream is closed
  {
    boost::archive::xml_iarchive ia( ifs );
    ia >> boost::serialization::make_nvp( "workspace", *this );
  }
  ifs.close();
}


void Workspace::saveXML( std::string &wsDir )
{
  std::ofstream ofs( wsDir );
  if( ofs.good() ) // due to xml_oarchive needs to be destroyed before fstream is closed
  {
    boost::archive::xml_oarchive oa( ofs );
    oa << boost::serialization::make_nvp( "workspace_manager", *this );
  }
  ofs.close();
}<commit_msg>FIXED Changed serialization workspace tag<commit_after>/*****************************************************************************\
 *                        ANALYSIS PERFORMANCE TOOLS                         *
 *                               libparaver-api                              *
 *                      API Library for libparaver-kernel                    *
 *****************************************************************************
 *     ___     This library is free software; you can redistribute it and/or *
 *    /  __         modify it under the terms of the GNU LGPL as published   *
 *   /  /  _____    by the Free Software Foundation; either version 2.1      *
 *  /  /  /     \   of the License, or (at your option) any later version.   *
 * (  (  ( B S C )                                                           *
 *  \  \  \_____/   This library is distributed in 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 LGPL for more details.   *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public License  *
 * along with this library; if not, write to the Free Software Foundation,   *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA          *
 * The GNU LEsser General Public License is contained in the file COPYING.   *
 *                                 ---------                                 *
 *   Barcelona Supercomputing Center - Centro Nacional de Supercomputacion   *
\*****************************************************************************/

#include "workspace.h"

using std::string;
using std::vector;
using std::pair;

Workspace::Workspace()
{
}

Workspace::~Workspace()
{
}

string Workspace::getName() const
{
  return name;
}

WorkspaceValue::WorkspaceType Workspace::getType() const
{
  return myType;
}

vector<WorkspaceValue> Workspace::getAutoTypes() const
{
  return autoTypes;
}

vector<pair<string,string> > Workspace::getHintCFGs() const
{
  return hintCFGs;
}

pair<string,string> Workspace::getHintCFG( size_t whichHint ) const
{
  return hintCFGs[ whichHint ];
}

void Workspace::setName( string& whichName )
{
  name = whichName;
}

void Workspace::setType( WorkspaceValue::WorkspaceType whichType )
{
  myType = whichType;
  for( vector<WorkspaceValue>::iterator it = autoTypes.begin(); it != autoTypes.end(); ++it )
    it->myType = whichType;
}

void Workspace::setAutoTypes( vector<WorkspaceValue>& whichAutoTypes )
{
  autoTypes = whichAutoTypes;
}

void Workspace::addHintCFG( pair<string,string>& whichCFG )
{
  hintCFGs.push_back( whichCFG );
}

void Workspace::addHintCFG( size_t position, pair<string,string>& whichCFG )
{
  hintCFGs.insert( hintCFGs.begin() + position, whichCFG );
}

void Workspace::removeHintCFG( size_t whichHint )
{
  hintCFGs.erase( hintCFGs.begin() + whichHint );
}

void Workspace::modifyHintCFG( size_t position, pair<string,string>& whichCFG )
{
  hintCFGs[ position ] = whichCFG;
}

void Workspace::clearHintCFGs()
{
  hintCFGs.clear();
}


// load/save XML for import/export certain workspaces

void Workspace::loadXML( std::string &wsDir )
{
  // Read user defined
  std::ifstream ifs( wsDir );
  //ifs.open( wsDir );
  if( ifs.good() ) // due to xml_iarchive needs to be destroyed before fstream is closed
  {
    boost::archive::xml_iarchive ia( ifs );
    ia >> boost::serialization::make_nvp( "workspace", *this );
  }
  ifs.close();
}


void Workspace::saveXML( std::string &wsDir )
{
  std::ofstream ofs( wsDir );
  if( ofs.good() ) // due to xml_oarchive needs to be destroyed before fstream is closed
  {
    boost::archive::xml_oarchive oa( ofs );
    oa << boost::serialization::make_nvp( "workspace", *this );
  }
  ofs.close();
}
{'fraction_non_alphanumeric': 0.16079127567841744, 'fraction_numerical': 0.003296981993406036, 'mean_word_length': 2.589895311788803, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7613046', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2204, 'n_words': 618}