<commit_before>/** 
 * @file prop_impl.h
 * @brief 
 * @author <NAME>
 * @date 2009-08-27
 */
#ifndef __PROP_IMPL_H
#define __PROP_IMPL_H

#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <list>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/string.hpp>

#include "throw_exception.h"
#include "misc.h"

template <class type_t>
class prop_impl
{
  //-----------------------
  // TYPE DECL
  // ----------------------
  public:
    struct prop_storage 
      {
        type_t value;
        type_t def_value;
        bool flag;
        std::string short_name;
        std::wstring description;
        
        template<class Archive>
        void serialize(Archive & ar, const unsigned int /*version*/)
          {
            ar & value;
            ar & def_value;
            ar & flag;
            ar & short_name;
            ar & description;
          }
      };

    typedef std::map<std::string, prop_storage> map_t;
    typedef std::list<std::string> list_t;
  // ----------------------
  // METHODS
  // ----------------------
  public:
    // constructor
    prop_impl () {};
    // destructor
    virtual ~prop_impl () {};

    // add new property
    void add (const type_t def_value, const std::string &short_name, const std::wstring &description);

    //! clear all
    void clear ()
      {
        data.clear ();
      }

    //! return property value
    const type_t get (const std::string &name) const
      {
        typename map_t::const_iterator i;

        i = data.find (name);<commit_msg>prop: serialize prop_storage via BS machinery, fix reals and wstrings issues<commit_after>/** 
 * @file prop_impl.h
 * @brief 
 * @author <NAME>
 * @date 2009-08-27
 */
#ifndef __PROP_IMPL_H
#define __PROP_IMPL_H

#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <list>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/string.hpp>

#include "throw_exception.h"
#include "misc.h"
#include "bs_serialize.h"

template< class type_t >
struct prop_storage_
  {
    type_t value;
    type_t def_value;
    bool flag;
    std::string short_name;
    std::wstring description;
    
    //template<class Archive>
    //void serialize(Archive & ar, const unsigned int /*version*/)
    //  {
    //    ar & value;
    //    ar & def_value;
    //    ar & flag;
    //    ar & short_name;
    //    ar & description;
    //  }
  };

BLUE_SKY_CLASS_SRZ_FCN_BEGIN_T(serialize, prop_storage_, 1)
  ar & t.value;
  ar & t.def_value;
  ar & t.flag;
  ar & t.short_name;
  ar & t.description;
BLUE_SKY_CLASS_SRZ_FCN_END

template <class type_t>
class prop_impl
{
  //-----------------------
  // TYPE DECL
  // ----------------------
  public:

    typedef prop_storage_< type_t > prop_storage;
    typedef std::map<std::string, prop_storage> map_t;
    typedef std::list<std::string> list_t;
  // ----------------------
  // METHODS
  // ----------------------
  public:
    // constructor
    prop_impl () {};
    // destructor
    virtual ~prop_impl () {};

    // add new property
    void add (const type_t def_value, const std::string &short_name, const std::wstring &description);

    //! clear all
    void clear ()
      {
        data.clear ();
      }

    //! return property value
    const type_t get (const std::string &name) const
      {
        typename map_t::const_iterator i;

        i = data.find (name);
{'fraction_non_alphanumeric': 0.16888406190605484, 'fraction_numerical': 0.004615802335052946, 'mean_word_length': 2.1379897785349233, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2824043', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1176, 'n_words': 280}