Changeset 1f24a1c in nscp for include


Ignore:
Timestamp:
02/20/11 15:43:50 (2 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
4c18192
Parents:
c760fc9
Message:

Syncronized streams so all new 0.3.9 features are now in 0.4.x as well

Location:
include
Files:
1 added
5 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • include/config.h.in

    rc760fc9 r1f24a1c  
    7575#define CRASH_SUBMIT_URL _T("http://crash.nsclient.org/submit") 
    7676#define CRASH_ARCHIVE_FOLDER _T("${shared-path}/crash-dumps") 
     77#define CRASH_ARCHIVE_FOLDER_KEY _T("folder") 
    7778 
    7879#ifdef WIN32 
  • include/file_helpers.hpp

    r497b779 r1f24a1c  
    66  class checks { 
    77  public: 
     8#ifdef WIN32 
     9    static bool is_directory(DWORD dwAttr) { 
     10      if (dwAttr == INVALID_FILE_ATTRIBUTES) { 
     11        return false; 
     12      } else if ((dwAttr&FILE_ATTRIBUTE_DIRECTORY)==FILE_ATTRIBUTE_DIRECTORY) { 
     13        return true; 
     14      } 
     15      return false; 
     16    } 
     17#endif 
    818    static bool is_directory(std::wstring path) { 
    919      return boost::filesystem::is_directory(path); 
    1020    } 
    11 //    static bool is_directory(DWORD dwAtt) { 
    12 //      if (dwAtt == INVALID_FILE_ATTRIBUTES) { 
    13 //        return false; 
    14 //      } else if ((dwAtt&FILE_ATTRIBUTE_DIRECTORY)==FILE_ATTRIBUTE_DIRECTORY) { 
    15 //        return true; 
    16 //      } 
    17 //      return false; 
    18 //    } 
    1921    static bool is_file(std::wstring path) { 
    2022      return boost::filesystem::is_regular(path); 
    21 //      DWORD dwAtt = ::GetFileAttributes(path.c_str()); 
    22 //      if (dwAtt == INVALID_FILE_ATTRIBUTES) { 
    23 //        return false; 
    24 //      } else if ((dwAtt&FILE_ATTRIBUTE_NORMAL)==FILE_ATTRIBUTE_NORMAL) { 
    25 //        return true; 
    26 //      } 
    27 //      return false; 
    2823    } 
    2924    static bool exists(std::wstring path) { 
    3025      return boost::filesystem::exists(path); 
    31 //      DWORD dwAtt = ::GetFileAttributes(path.c_str()); 
    32 //      if (dwAtt == INVALID_FILE_ATTRIBUTES) { 
    33 //        return false; 
    34 //      } 
    35 //      return true; 
    3626    } 
    3727  }; 
     
    6454      return pattern_type(path.branch_path(), path.leaf() /*filename()*/); 
    6555    } 
     56    static pattern_type split_path_ex(std::wstring path) { 
     57      std::wstring baseDir; 
     58      if (file_helpers::checks::is_directory(path)) { 
     59        return pattern_type(path, _T("")); 
     60      } 
     61      std::wstring::size_type pos = path.find_last_of('\\'); 
     62      if (pos == std::wstring::npos) { 
     63        pattern_type(path, _T("*.*")); 
     64      } 
     65      return pattern_type(path.substr(0, pos), path.substr(pos+1)); 
     66    } 
    6667    static boost::filesystem::wpath combine_pattern(pattern_type pattern) { 
    6768      return pattern.first / pattern.second; 
    6869    } 
    69  
    70  
    71   }; 
    72  
     70  }; // END patterns 
    7371} 
  • include/nrpe/server/server.cpp

    r1ecd26f r1f24a1c  
    3232        endpoint_iterator = resolver.resolve(ip::tcp::resolver::query(info.get_port())); 
    3333      } else { 
    34         endpoint_iterator = resolver.resolve(ip::tcp::resolver::query(info.get_address(), info.port)); 
     34        endpoint_iterator = resolver.resolve(ip::tcp::resolver::query(info.get_address(), info.get_port())); 
    3535      } 
    3636      ip::tcp::resolver::iterator end; 
  • include/parsers/ast.hpp

    r1ecd26f r1f24a1c  
    2222namespace parsers { 
    2323  namespace where { 
    24     template<typename THandler> 
    25     struct binary_op; 
    26     template<typename THandler> 
    27     struct unary_op; 
    28     template<typename THandler> 
    29     struct unary_fun; 
    30     struct string_value; 
    31     struct int_value; 
    3224 
    33     template<typename THandler> 
    34     struct list_value; 
    35  
    36     template<typename THandler> 
    37     struct variable; 
    38     struct nil {}; 
    39  
    40     enum operators { 
    41       op_eq, op_le, op_lt, op_gt, op_ge, op_ne, op_in, op_nin, op_or, op_and, op_inv, op_not, op_like, op_not_like 
    42     }; 
    43  
    44     enum value_type { 
    45       type_invalid = 99, type_tbd = 66, 
    46       type_int = 1, type_bool = 2,  
    47       type_string = 10,  
    48       type_date = 20,  
    49       type_custom_int = 1024, 
    50       type_custom_int_1 = 1024+1, 
    51       type_custom_int_2 = 1024+2, 
    52       type_custom_int_3 = 1024+3, 
    53       type_custom_int_4 = 1024+4, 
    54       type_custom_int_end = 1024+100, 
    55       type_custom_string = 2048, 
    56       type_custom_string_1 = 2048+1, 
    57       type_custom_string_2 = 2048+2, 
    58       type_custom_string_3 = 2048+3, 
    59       type_custom_string_4 = 2048+4, 
    60       type_custom_string_end = 2048+100, 
    61       type_custom = 4096, 
    62       type_custom_1 = 4096+1, 
    63       type_custom_2 = 4096+2, 
    64       type_custom_3 = 4096+3, 
    65       type_custom_4 = 4096+4 
    66     }; 
    67  
    68     struct varible_type_handler { 
    69       virtual bool has_variable(std::wstring) = 0; 
    70       virtual value_type get_type(std::wstring) = 0; 
    71       virtual void error(std::wstring) = 0; 
    72       virtual bool can_convert(value_type from, value_type to) = 0; 
    73     }; 
    74  
    75  
    76     inline bool type_is_int(value_type type) { 
    77       return type == type_int || type == type_bool || type == type_date || (type >= type_custom_int && type < type_custom_int_end); 
    78     } 
    79  
    80     inline value_type get_return_type(operators op, value_type type) { 
    81       if (op == op_inv) 
    82         return type; 
    83       return type_bool; 
    84     } 
    85     inline std::wstring to_string(value_type type) { 
    86       if (type == type_bool) 
    87         return _T("bool"); 
    88       if (type == type_string) 
    89         return _T("string"); 
    90       if (type == type_int) 
    91         return _T("int"); 
    92       if (type == type_date) 
    93         return _T("date"); 
    94       if (type == type_invalid) 
    95         return _T("invalid"); 
    96       if (type == type_tbd) 
    97         return _T("tbd"); 
    98       if (type >= type_custom) 
    99         return _T("u:") + strEx::itos(type-type_custom); 
    100       if (type >= type_custom_string) 
    101         return _T("us:") + strEx::itos(type-type_custom_string); 
    102       if (type >= type_custom_int) 
    103         return _T("ui:") + strEx::itos(type-type_custom_int); 
    104       return _T("unknown:") + strEx::itos(type); 
    105     } 
    106     inline std::wstring type_to_string(value_type type) { 
    107       return to_string(type); 
    108     } 
    109  
    110     inline std::wstring operator_to_string(operators const& identifier) { 
    111       if (identifier == op_and) 
    112         return _T("and"); 
    113       if (identifier == op_or) 
    114         return _T("or"); 
    115       if (identifier == op_eq) 
    116         return _T("="); 
    117       if (identifier == op_gt) 
    118         return _T(">"); 
    119       if (identifier == op_lt) 
    120         return _T("<"); 
    121       if (identifier == op_ge) 
    122         return _T(">="); 
    123       if (identifier == op_le) 
    124         return _T("<="); 
    125       if (identifier == op_in) 
    126         return _T("in"); 
    127       if (identifier == op_nin) 
    128         return _T("not in"); 
    129       return _T("?"); 
    130     } 
    131  
    132     typedef boost::variant<nil,unsigned int,std::wstring> list_value_type; 
    133     typedef std::list<list_value_type> list_type; 
    134  
    135     struct parsing_exception {}; 
    136  
    137     template<typename THandler> 
    138     struct expression_ast { 
    139       typedef 
    140         boost::variant< 
    141         nil // can't happen! 
    142         //, identifier_type 
    143         , boost::recursive_wrapper<expression_ast<THandler> > 
    144         , boost::recursive_wrapper<list_value<THandler> > 
    145         , boost::recursive_wrapper<unary_fun<THandler> > 
    146         , boost::recursive_wrapper<binary_op<THandler> > 
    147         , boost::recursive_wrapper<unary_op<THandler> > 
    148         , boost::recursive_wrapper<string_value> 
    149         , boost::recursive_wrapper<int_value> 
    150         , boost::recursive_wrapper<variable<THandler> > 
    151         > 
    152         payload_type; 
    153       typedef std::list<expression_ast<typename THandler> > list_type; 
    154  
    155       expression_ast() : expr(nil()), type(type_tbd) {} 
    156  
    157       template <typename Expr> 
    158       expression_ast(Expr const& expr_) : expr(expr_), type(type_tbd) {} 
    159  
    160       expression_ast<THandler>& operator&=(expression_ast<THandler> const& rhs); 
    161       expression_ast<THandler>& operator|=(expression_ast<THandler> const& rhs); 
    162       expression_ast<THandler>& operator!=(expression_ast<THandler> const& rhs); 
    163  
    164       payload_type expr; 
    165       value_type type; 
    166  
    167       value_type get_type() const { return type; } 
    168       void set_type( value_type newtype); 
    169  
    170       std::wstring to_string() const; 
    171  
    172       void force_type(value_type newtype); 
    173       long long get_int(THandler &handler) const; 
    174       std::wstring get_string(THandler &handler) const;  
    175       list_type get_list() const; 
    176  
    177       bool can_evaluate() const; 
    178       expression_ast<THandler> evaluate(THandler &handler) const; 
    179       bool bind(THandler &handler); 
    180  
    181     }; 
    182  
    183     template <typename THandler> 
    184     struct varible_handler : public varible_type_handler { 
    185       typedef boost::function<std::wstring(THandler*)> bound_string_type; 
    186       typedef boost::function<long long(THandler*)> bound_int_type; 
    187       typedef boost::function<expression_ast<THandler>(THandler*,value_type,expression_ast<THandler> const&)> bound_function_type; 
    188  
    189       virtual bound_string_type bind_string(std::wstring key) = 0; 
    190       virtual bound_int_type bind_int(std::wstring key) = 0; 
    191       virtual bool has_function(value_type to, std::wstring name, expression_ast<THandler> subject) = 0; 
    192       virtual bound_function_type bind_function(value_type to, std::wstring name, expression_ast<THandler> subject) = 0; 
    193     }; 
    194  
    195  
    196     template<typename THandler> 
    197     struct binary_operator_impl { 
    198       virtual expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const = 0; 
    199     }; 
    200     template<typename THandler> 
    201     struct binary_function_impl { 
    202       virtual expression_ast<THandler> evaluate(value_type type, THandler &handler, const expression_ast<THandler> &subject) const = 0; 
    203     }; 
    204     template<typename THandler> 
    205     struct unary_operator_impl { 
    206       virtual expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &subject) const = 0; 
    207     }; 
    208  
    209 //  
    210     template<typename THandler> 
    211     struct list_value { 
    212       list_value() { 
    213       } 
    214       list_value(expression_ast<THandler> const& subject) { 
    215         list.push_back(subject); 
    216       } 
    217       void append(expression_ast<THandler> const& subject) { 
    218         list.push_back(subject); 
    219       } 
    220       list_value<THandler>& operator+=(expression_ast<THandler> const& subject) { 
    221         list.push_back(subject); 
    222         return *this; 
    223       } 
    224  
    225       typedef std::list<expression_ast<THandler> > list_type; 
    226       list_type list; 
    227     }; 
    228  
    229     template<typename THandler> 
    230     struct binary_op { 
    231       binary_op(operators op, expression_ast<THandler> const& left, expression_ast<THandler> const& right): op(op), left(left), right(right) {} 
    232  
    233       expression_ast<THandler> evaluate(THandler &handler) const; 
    234  
    235       operators op; 
    236       expression_ast<THandler> left; 
    237       expression_ast<THandler> right; 
    238     }; 
    239  
    240     template<typename THandler> 
    241     struct unary_op { 
    242       unary_op(operators op, expression_ast<THandler> const& subject): op(op), subject(subject) {} 
    243  
    244       expression_ast<THandler> evaluate(THandler &handler) const; 
    245  
    246       operators op; 
    247       expression_ast<THandler> subject; 
    248     }; 
    249  
    250     template<typename THandler> 
    251     struct unary_fun { 
    252       boost::function<expression_ast<THandler>(THandler*,value_type,expression_ast<THandler> const&)> e_fn; 
    253       boost::shared_ptr<binary_function_impl<typename THandler> > i_fn; 
    254  
    255       unary_fun(std::wstring name, expression_ast<THandler> const& subject): name(name), subject(subject) {} 
    256  
    257       expression_ast<THandler> evaluate(value_type type, THandler &handler) const; 
    258  
    259       bool bind(value_type type, THandler & handler); 
    260       std::wstring name; 
    261       expression_ast<THandler> subject; 
    262       bool is_transparent(value_type type); 
    263       bool is_bound() const; 
    264     }; 
    265  
    266     struct string_value { 
    267       string_value(std::wstring value) : value(value) {} 
    268  
    269       std::wstring value; 
    270     }; 
    271     struct int_value { 
    272       int_value(long long value) : value(value) {} 
    273  
    274       long long value; 
    275  
    276     }; 
    277     template<typename THandler> 
    278     struct variable { 
    279       boost::function<long long(THandler*)> i_fn; 
    280       boost::function<std::wstring(THandler*)> s_fn; 
    281       variable(std::wstring name) : name(name) {} 
    282  
    283       bool bind(value_type type, THandler & handler); 
    284       long long get_int(THandler & instance) const; 
    285       std::wstring get_string(THandler & instance) const; 
    286  
    287       std::wstring name; 
    288     }; 
    28925  } 
    29026} 
  • include/parsers/eval.hpp

    r1ecd26f r1f24a1c  
    11#pragma once 
     2 
     3#include <parsers/where/expression_ast.hpp> 
    24 
    35namespace parsers { 
     
    68      template<typename THandler> 
    79      struct simple_bool_binary_operator_impl : public binary_operator_impl<THandler> { 
    8         expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     10        typedef typename THandler::object_type object_type; 
     11        expression_ast<THandler> evaluate(object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    912          value_type ltype = left.get_type(); 
    1013          value_type rtype = right.get_type(); 
     
    2225          return expression_ast<THandler>(int_value(FALSE)); 
    2326        } 
    24         virtual bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const = 0; 
    25         virtual bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const = 0; 
     27        virtual bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const = 0; 
     28        virtual bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const = 0; 
     29      }; 
     30 
     31      template<typename THandler> 
     32      struct simple_int_binary_operator_impl : public binary_operator_impl<THandler> { 
     33        typedef typename THandler::object_type object_type; 
     34        expression_ast<THandler> evaluate(object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     35          value_type ltype = left.get_type(); 
     36          value_type rtype = right.get_type(); 
     37 
     38          if ( (ltype != rtype) && (rtype != type_tbd) ) { 
     39            handler.error(_T("Invalid types (not same) for binary operator")); 
     40            return expression_ast<THandler>(int_value(FALSE)); 
     41          } 
     42          value_type type = left.get_type(); 
     43          if (type_is_int(type)) 
     44            return expression_ast<THandler>(int_value(eval_int(type, handler, left, right))); 
     45          if (type == type_string) 
     46            return expression_ast<THandler>(int_value(eval_string(type, handler, left, right))); 
     47          handler.error(_T("missing impl for simple bool binary operator")); 
     48          return expression_ast<THandler>(int_value(FALSE)); 
     49        } 
     50        virtual long long eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const = 0; 
     51        virtual long long eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const = 0; 
    2652      }; 
    2753 
    2854      template<typename THandler> 
    2955      struct operator_and : public simple_bool_binary_operator_impl<THandler> { 
    30         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     56        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    3157          return left.get_int(handler) && right.get_int(handler); 
    3258        } 
    33         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     59        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    3460          handler.error(_T("missing impl for and binary operator")); 
    3561          // TODO convert strings 
     
    3965      template<typename THandler> 
    4066      struct operator_or : public simple_bool_binary_operator_impl<THandler> { 
    41         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     67        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    4268          return left.get_int(handler) || right.get_int(handler); 
    4369        } 
    44         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     70        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    4571          handler.error(_T("missing impl for or binary operator")); 
    4672          // TODO convert strings 
     
    5076      template<typename THandler> 
    5177      struct operator_eq : public simple_bool_binary_operator_impl<THandler> { 
    52         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     78        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    5379          return left.get_int(handler) == right.get_int(handler); 
    5480        } 
    55         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     81        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    5682          return left.get_string(handler) == right.get_string(handler); 
    5783        }; 
     
    5985      template<typename THandler> 
    6086      struct operator_ne : public simple_bool_binary_operator_impl<THandler> { 
    61         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     87        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    6288          return left.get_int(handler) != right.get_int(handler); 
    6389        } 
    64         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     90        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    6591          return left.get_string(handler) != right.get_string(handler); 
    6692        }; 
     
    6894      template<typename THandler> 
    6995      struct operator_gt : public simple_bool_binary_operator_impl<THandler> { 
    70         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     96        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    7197          return left.get_int(handler) > right.get_int(handler); 
    7298        } 
    73         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     99        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    74100          return left.get_string(handler) > right.get_string(handler); 
    75101        }; 
     
    77103      template<typename THandler> 
    78104      struct operator_lt : public simple_bool_binary_operator_impl<THandler> { 
    79         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     105        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    80106          return left.get_int(handler) < right.get_int(handler); 
    81107        } 
    82         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     108        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    83109          return left.get_string(handler) < right.get_string(handler); 
    84110        }; 
     
    86112      template<typename THandler> 
    87113      struct operator_le : public simple_bool_binary_operator_impl<THandler> { 
    88         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     114        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    89115          return left.get_int(handler) <= right.get_int(handler); 
    90116        } 
    91         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     117        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    92118          return left.get_string(handler) <= right.get_string(handler); 
    93119        }; 
     
    95121      template<typename THandler> 
    96122      struct operator_ge : public simple_bool_binary_operator_impl<THandler> { 
    97         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     123        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    98124          return left.get_int(handler) >= right.get_int(handler); 
    99125        } 
    100         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     126        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    101127          return left.get_string(handler) >= right.get_string(handler); 
    102128        }; 
    103129      }; 
     130 
     131 
     132      template<typename THandler> 
     133      struct operator_bin_and : public simple_int_binary_operator_impl<THandler> { 
     134        long long eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     135          return left.get_int(handler) & right.get_int(handler); 
     136        } 
     137        long long eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     138          return 0; 
     139        }; 
     140      }; 
     141      template<typename THandler> 
     142      struct operator_bin_or : public simple_int_binary_operator_impl<THandler> { 
     143        long long eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     144          return left.get_int(handler) | right.get_int(handler); 
     145        } 
     146        long long eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     147          return 0; 
     148        }; 
     149      }; 
     150 
    104151      template<typename THandler> 
    105152      struct operator_like : public simple_bool_binary_operator_impl<THandler> { 
    106         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    107           return false; 
    108         } 
    109         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     153        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     154          return false; 
     155        } 
     156        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    110157          std::wstring s1 = left.get_string(handler); 
    111158          std::wstring s2 = right.get_string(handler); 
     
    121168      template<typename THandler> 
    122169      struct operator_not_like : public simple_bool_binary_operator_impl<THandler> { 
    123         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    124           return false; 
    125         } 
    126         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
     170        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     171          return false; 
     172        } 
     173        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const {  
    127174          std::wstring s1 = left.get_string(handler); 
    128175          std::wstring s2 = right.get_string(handler); 
     
    144191        operator_not_in(const expression_ast<THandler> &subject) : list(subject.get_list()) {} 
    145192 
    146         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     193        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    147194          long long val = left.get_int(handler); 
    148195          BOOST_FOREACH(list_item_type itm, list) { 
     
    152199          return true; 
    153200        } 
    154         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     201        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    155202          std::wstring val = left.get_string(handler); 
    156203          BOOST_FOREACH(list_item_type itm, list) { 
     
    169216        operator_in(const expression_ast<THandler> &subject) : list(subject.get_list()) {} 
    170217 
    171         bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     218        bool eval_int(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    172219          long long val = left.get_int(handler); 
    173220          BOOST_FOREACH(list_item_type itm, list) { 
     
    177224          return false; 
    178225        } 
    179         bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     226        bool eval_string(value_type type, typename THandler::object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    180227          std::wstring val = left.get_string(handler); 
    181228          BOOST_FOREACH(list_item_type itm, list) { 
     
    188235      template<typename THandler> 
    189236      struct operator_false : public binary_operator_impl<THandler>, unary_operator_impl<THandler>, binary_function_impl<THandler> { 
    190         expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     237        typedef typename THandler::object_type object_type; 
     238        expression_ast<THandler> evaluate(object_type &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    191239          handler.error(_T("missing impl for FALSE")); 
    192240          return expression_ast<THandler>(int_value(FALSE)); 
    193241        } 
    194         expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &subject) const { 
     242        expression_ast<THandler> evaluate(object_type &handler, const expression_ast<THandler> &subject) const { 
    195243          handler.error(_T("missing impl for FALSE")); 
    196244          return expression_ast<THandler>(int_value(FALSE)); 
    197245        } 
    198         expression_ast<THandler> evaluate(parsers::where::value_type type,THandler &handler, const expression_ast<THandler> &subject) const { 
     246        expression_ast<THandler> evaluate(parsers::where::value_type type, object_type &handler, const expression_ast<THandler> &subject) const { 
    199247          handler.error(_T("missing impl for FALSE")); 
    200248          return expression_ast<THandler>(int_value(FALSE)); 
     
    206254        typename expression_ast<THandler> list_entry; 
    207255        typedef typename expression_ast<THandler>::list_type list_type; 
     256        typedef typename THandler::object_type object_type; 
    208257        typename expression_ast<THandler>::list_type list; 
    209258        bool single_item; 
    210259        function_convert(const expression_ast<THandler> &subject) : list(subject.get_list()), single_item(list.size()==1) {} 
    211         expression_ast<THandler> evaluate(value_type type, THandler &handler, const expression_ast<THandler> &subject) const { 
     260        expression_ast<THandler> evaluate(value_type type, object_type &object, const expression_ast<THandler> &subject) const { 
    212261          if (single_item) { 
    213262            if (type_is_int(type)) { 
    214               return expression_ast<THandler>(int_value(list.front().get_int(handler))); 
     263              return expression_ast<THandler>(int_value(list.front().get_int(object))); 
    215264            } 
    216265            if (type == type_string) { 
    217               return expression_ast<THandler>(string_value(list.front().get_string(handler))); 
     266              return expression_ast<THandler>(string_value(list.front().get_string(object))); 
    218267            } 
    219             handler.error(_T("1:Failed to handle type: ") + to_string(type)); 
     268            object.error(_T("1:Failed to handle type: ") + to_string(type)); 
    220269            return expression_ast<THandler>(int_value(FALSE)); 
    221270          } 
     
    225274            std::advance(unit, 1); 
    226275            if (type == type_date) { 
    227               return expression_ast<THandler>(int_value(parse_time((*item).get_int(handler), (*unit).get_string(handler)))); 
     276              return expression_ast<THandler>(int_value(parse_time((*item).get_int(object), (*unit).get_string(object)))); 
    228277            } 
    229             handler.error(_T("m:Failed to handle type: ") + to_string(type) + _T(" ") + (*item).to_string() + _T(", ") + (*unit).to_string()); 
     278            if (type == type_size) { 
     279              return expression_ast<THandler>(int_value(parse_size((*item).get_int(object), (*unit).get_string(object)))); 
     280            } 
     281            object.error(_T("m:Failed to handle type: ") + to_string(type) + _T(" ") + (*item).to_string() + _T(", ") + (*unit).to_string()); 
    230282            return expression_ast<THandler>(int_value(FALSE)); 
    231283          } 
     
    234286          std::wcout << subject.to_string() << _T("\n"); 
    235287          std::wcout << _T("----------------------------------------------\n"); 
    236           handler.error(_T("Missing implementation for convert function")); 
    237           return expression_ast<THandler>(int_value(FALSE)); 
    238         } 
    239  
    240         inline long long parse_time(unsigned int value, std::wstring unit) const { 
     288          object.error(_T("Missing implementation for convert function")); 
     289          return expression_ast<THandler>(int_value(FALSE)); 
     290        } 
     291 
     292        inline long long parse_time(long long value, std::wstring unit) const { 
    241293          long long now = constants::get_now(); 
    242294          if (unit.empty()) 
     
    255307        } 
    256308 
     309        inline long long parse_size(long long value, std::wstring unit) const { 
     310          long long now = constants::get_now(); 
     311          if (unit.empty()) 
     312            return now + value; 
     313          else if ( (unit == _T("b")) || (unit == _T("B")) ) 
     314            return now + (value); 
     315          else if ( (unit == _T("k")) || (unit == _T("k")) ) 
     316            return now + (value * 1024); 
     317          else if ( (unit == _T("m")) || (unit == _T("M")) ) 
     318            return now + (value * 1024 * 1024); 
     319          else if ( (unit == _T("g")) || (unit == _T("G")) ) 
     320            return now + (value * 1024 * 1024 * 1024); 
     321          else if ( (unit == _T("t")) || (unit == _T("T")) ) 
     322            return now + (value * 1024 * 1024 * 1024 * 1024); 
     323          return now + value; 
     324        } 
     325         
    257326      }; 
    258327 
     
    260329      template<typename THandler> 
    261330      struct simple_bool_unary_operator_impl : public unary_operator_impl<THandler> { 
    262         expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &subject) const { 
     331        typedef typename THandler::object_type object_type; 
     332        expression_ast<THandler> evaluate(object_type &object, const expression_ast<THandler> &subject) const { 
    263333          value_type type = subject.get_type(); 
    264334          if (type_is_int(type)) 
    265             return eval_int(type, handler, subject)?expression_ast<THandler>(int_value(TRUE)):expression_ast<THandler>(int_value(FALSE)); 
     335            return eval_int(type, object, subject)?expression_ast<THandler>(int_value(TRUE)):expression_ast<THandler>(int_value(FALSE)); 
    266336          if (type == type_string) 
    267             return eval_string(type, handler, subject)?expression_ast<THandler>(int_value(TRUE)):expression_ast<THandler>(int_value(FALSE)); 
    268           handler.error(_T("missing impl for bool unary operator")); 
     337            return eval_string(type, object, subject)?expression_ast<THandler>(int_value(TRUE)):expression_ast<THandler>(int_value(FALSE)); 
     338          object.error(_T("missing impl for bool unary operator")); 
    269339          return expression_ast<THandler>(int_value(FALSE)); 
    270340        } 
     
    275345      template<typename THandler> 
    276346      struct operator_not : public unary_operator_impl<THandler>, binary_function_impl<THandler> { 
     347        typedef typename THandler::object_type object_type; 
    277348        operator_not(const expression_ast<THandler> &subject) {} 
    278349        operator_not() {} 
    279         expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &subject) const { 
    280           return evaluate(subject.get_type(), handler, subject); 
    281         } 
    282         expression_ast<THandler> evaluate(value_type type, THandler &handler, const expression_ast<THandler> &subject) const { 
     350        expression_ast<THandler> evaluate(object_type &object, const expression_ast<THandler> &subject) const { 
     351          return evaluate(subject.get_type(), object, subject); 
     352        } 
     353        expression_ast<THandler> evaluate(value_type type, object_type &object, const expression_ast<THandler> &subject) const { 
    283354          if (type == type_bool) 
    284             return subject.get_int(handler)?expression_ast<THandler>(int_value(TRUE)):expression_ast<THandler>(int_value(FALSE)); 
     355            return subject.get_int(object)?expression_ast<THandler>(int_value(TRUE)):expression_ast<THandler>(int_value(FALSE)); 
    285356          if (type == type_int) 
    286             return  expression_ast<THandler>(int_value(-subject.get_int(handler))); 
     357            return  expression_ast<THandler>(int_value(-subject.get_int(object))); 
    287358          if (type == type_date) { 
    288359            long long now = constants::get_now(); 
    289             long long val = now - (subject.get_int(handler) - now); 
     360            long long val = now - (subject.get_int(object) - now); 
    290361            return expression_ast<THandler>(int_value(val)); 
    291362          } 
    292           handler.error(_T("missing impl for NOT operator")); 
     363          object.error(_T("missing impl for NOT operator")); 
    293364          return expression_ast<THandler>(int_value(FALSE)); 
    294365        } 
    295366      }; 
    296367    } 
     368 
    297369    template<typename THandler> 
    298370    typename factory<THandler>::bin_op_type factory<THandler>::get_binary_operator(operators op, const expression_ast<THandler> &left, const expression_ast<THandler> &right) { 
     
    323395      if (op == op_nin) 
    324396        return bin_op_type(new operator_impl::operator_not_in<THandler>(right)); 
     397 
     398      if (op == op_binand) 
     399        return bin_op_type(new operator_impl::operator_bin_and<THandler>()); 
     400      if (op == op_binor) 
     401        return bin_op_type(new operator_impl::operator_bin_or<THandler>()); 
     402 
    325403      std::cout << "======== UNHANDLED OPERATOR\n"; 
    326404      return bin_op_type(new operator_impl::operator_false<THandler>()); 
  • include/parsers/helpers.cpp

    redf0848 r1f24a1c  
    1111    } 
    1212    void constants::reset() { 
    13       __time64_t ltime; 
    14       _time64(&ltime); 
    15       now = ltime; 
     13      __time64_t utctime; 
     14      _time64(&utctime); 
     15      now = utctime; 
     16//      struct tm localtime; 
     17//      _localtime64_s(&localtime, &utctime); 
     18//      now = _mktime64(&localtime); 
    1619    } 
    1720 
  • include/parsers/where.hpp

    r9661f81 r1f24a1c  
    1515#include <strEx.h> 
    1616 
    17 #include <parsers/ast.hpp> 
     17#include <parsers/where/expression_ast.hpp> 
     18#include <parsers/where/operators_impl.hpp> 
     19#include <parsers/where/varible_handler.hpp> 
     20#include <parsers/helpers.hpp> 
     21#include <parsers/where/grammar/grammar.hpp> 
     22#include <parsers/where/ast_type_inference.hpp> 
     23#include <parsers/where/ast_static_eval.hpp> 
     24#include <parsers/where/ast_bind.hpp> 
     25#include <parsers/where/list_value.hpp> 
     26#include <parsers/where/unary_fun.hpp> 
     27#include <parsers/where/operators.hpp> 
     28#include <parsers/where/variable.hpp> 
     29#include <parsers/where/ast_bind.hpp> 
     30#include <parsers/where/ast_visitors.hpp> 
     31#include <parsers/where/expression_ast_impl.hpp> 
     32#include <parsers/where/operators_impl.hpp> 
     33#include <parsers/where/grammar/grammar_impl.hpp> 
     34//#include <parsers/eval.hpp> 
    1835 
    1936namespace parsers { 
     
    2744 
    2845      static bin_op_type get_binary_operator(operators op, const expression_ast<THandler> &left, const expression_ast<THandler> &right); 
    29       //static bin_op_type get_binary_operator(operators op); 
    30       //static varible_handler::bound_function_type get_binary_function(std::wstring name, const expression_ast<THandler> &subject); 
    3146      static bin_fun_type get_binary_function(std::wstring name, const expression_ast<THandler> &subject); 
    3247      static un_op_type get_unary_operator(operators op); 
     
    3651    template<typename THandler> 
    3752    struct parser { 
     53      typedef typename THandler::object_type object_type; 
    3854      expression_ast<THandler> resulting_tree; 
    3955      std::wstring rest; 
     
    4258      bool static_eval(THandler & handler); 
    4359      bool bind(THandler & handler); 
    44       bool evaluate(THandler & handler); 
     60      bool evaluate(object_type & object); 
    4561      std::wstring result_as_tree() const; 
    4662    }; 
     63 
     64 
     65    template<typename THandler> 
     66    bool parser<THandler>::parse(std::wstring expr) { 
     67      constants::reset(); 
     68      //std::wcout << _T("Current time is: ") << constants::get_now() << std::endl; 
     69      typedef std::wstring::const_iterator iterator_type; 
     70      typedef where_grammar<THandler, iterator_type> grammar; 
     71 
     72      grammar calc; // Our grammar 
     73 
     74      iterator_type iter = expr.begin(); 
     75      iterator_type end = expr.end(); 
     76      if (phrase_parse(iter, end, calc, ascii::space, resulting_tree)) { 
     77        rest = std::wstring(iter, end); 
     78        return rest.empty(); 
     79        //std::wcout<< _T("Rest: ") << rest << std::endl; 
     80        //return true; 
     81      } 
     82      rest = std::wstring(iter, end); 
     83      //std::wcout << _T("Rest: ") << rest << std::endl; 
     84      return false; 
     85    } 
     86 
     87    template<typename THandler> 
     88    bool parser<THandler>::derive_types(THandler & handler) { 
     89      try { 
     90        ast_type_inference<THandler> resolver(handler); 
     91        resolver(resulting_tree); 
     92        return true; 
     93      } catch (...) { 
     94        handler.error(_T("Unhandled exception resolving types: ") + result_as_tree()); 
     95        return false; 
     96      } 
     97    } 
     98 
     99    template<typename THandler> 
     100    bool parser<THandler>::static_eval(THandler & handler) { 
     101      try { 
     102        ast_static_eval<THandler> evaluator(handler); 
     103        evaluator(resulting_tree); 
     104        return true; 
     105      } catch (...) { 
     106        handler.error(_T("Unhandled exception static eval: ") + result_as_tree()); 
     107        return false; 
     108      } 
     109    } 
     110    template<typename THandler> 
     111    bool parser<THandler>::bind(THandler & handler) { 
     112      try { 
     113        ast_bind<THandler> binder(handler); 
     114        binder(resulting_tree); 
     115        return true; 
     116      } catch (...) { 
     117        handler.error(_T("Unhandled exception static eval: ") + result_as_tree()); 
     118        return false; 
     119      } 
     120    } 
     121 
     122    template<typename THandler> 
     123    bool parser<THandler>::evaluate(object_type & object) { 
     124      try { 
     125        expression_ast<THandler> ast = resulting_tree.evaluate(object); 
     126        return ast.get_int(object) == 1; 
     127      } catch (...) { 
     128        object.error(_T("Unhandled exception static eval: ") + result_as_tree()); 
     129        return false; 
     130      } 
     131    } 
     132 
     133    template<typename THandler> 
     134    std::wstring parser<THandler>::result_as_tree() const { 
     135      return resulting_tree.to_string(); 
     136    } 
    47137  } 
    48138} 
  • include/socket_helpers.hpp

    racf0660 r1f24a1c  
    33#include <boost/foreach.hpp> 
    44#include <boost/bind.hpp> 
     5#include <boost/optional.hpp> 
    56 
    67namespace socketHelpers { 
  • include/strEx.h

    r87cf3c4 r1f24a1c  
    170170    lst += append; 
    171171  } 
    172 /* 
    173   inline std::string wstring_to_string( const wchar_t* pStr, int len) { 
    174     if (pStr == NULL) 
    175       throw string_exception(_T("Invalid pointer in wstring_to_string")); 
    176     if (len < 0 && len != -1)  
    177       throw string_exception(_T("Invalid string length in wstring_to_string")); 
    178  
    179     // figure out how many narrow characters we are going to get  
    180     int nChars = WideCharToMultiByte( CP_ACP , 0 , pStr , len , NULL , 0 , NULL , NULL ) ;  
    181     if ( len == -1 ) 
    182       -- nChars ;  
    183     if ( nChars == 0 ) 
    184       return "" ; 
    185  
    186     // convert the wide string to a narrow string 
    187     // nb: slightly naughty to write directly into the string like this 
    188     std::string buf ; 
    189     buf.resize( nChars ) ; 
    190     WideCharToMultiByte( CP_ACP , 0 , pStr , len ,  
    191       const_cast<char*>(buf.c_str()) , nChars , NULL , NULL ) ;  
    192  
    193     return buf ;  
    194   } 
    195   */ 
     172  inline void append_list_ex(std::wstring &lst, std::wstring append, std::wstring sep = _T(", ")) { 
     173    if (append.empty()) 
     174      return; 
     175    if (!lst.empty()) 
     176      lst += sep; 
     177    lst += append; 
     178  } 
    196179  inline std::string wstring_to_string( const std::wstring& str ) { 
    197180    return boost::lexical_cast<std::string>(str) ; 
    198     //return wstring_to_string(str.c_str(), static_cast<int>(str.length())); 
    199   } 
    200 /* 
    201   inline std::wstring string_to_wstring( const char* pStr , int len ) { 
    202     if (pStr == NULL) 
    203       throw string_exception(_T("Invalid pointer in wstring_to_string")); 
    204     if (len < 0 && len != -1)  
    205       throw string_exception(_T("Invalid string length in wstring_to_string")); 
    206  
    207     // figure out how many wide characters we are going to get  
    208     int nChars = MultiByteToWideChar( CP_ACP , 0 , pStr , len , NULL , 0 ) ;  
    209     if ( len == -1 ) 
    210       -- nChars ;  
    211     if ( nChars == 0 ) 
    212       return L"" ; 
    213  
    214     // convert the narrow string to a wide string  
    215     // nb: slightly naughty to write directly into the string like this 
    216     std::wstring buf ; 
    217     buf.resize( nChars ) ;  
    218     MultiByteToWideChar( CP_ACP , 0 , pStr , len , const_cast<wchar_t*>(buf.c_str()) , nChars ) ;  
    219  
    220     return buf ; 
    221   } 
    222   */ 
     181  } 
    223182  inline std::wstring string_to_wstring( const std::string& str ) { 
    224183    return boost::lexical_cast<std::wstring>(str) ; 
    225     //return string_to_wstring(str.c_str(), static_cast<int>(str.length())) ; 
    226184  } 
    227185 
     
    281239    return ss; 
    282240  } 
    283  
    284  
    285   inline std::wstring format_date(std::time_t time, std::wstring format = _T("%Y-%m-%d %H:%M:%S")) { 
    286     return format_date(boost::posix_time::from_time_t(time), format); 
    287   } 
    288   /* 
     241#ifdef WIN32 
    289242  inline std::wstring format_date(const SYSTEMTIME &time, std::wstring format = _T("%Y-%m-%d %H:%M:%S")) { 
     243    TCHAR buf[51]; 
     244 
    290245    struct tm tmTime; 
    291246    memset(&tmTime, 0, sizeof(tmTime)); 
     
    305260    return buf; 
    306261  } 
    307 #define MK_FORMAT_FTD(min, key, val) \ 
    308   if (mtm->tm_year > min) \ 
    309   strEx::replace(format, key, strEx::itos(val));  \ 
    310   else  \ 
    311   strEx::replace(format, key, _T("0")); 
    312  
    313  
    314  
     262#endif 
     263 
     264 
     265  inline std::wstring format_date(std::time_t time, std::wstring format = _T("%Y-%m-%d %H:%M:%S")) { 
     266    return format_date(boost::posix_time::from_time_t(time), format); 
     267  } 
     268 
     269   
    315270  static const __int64 SECS_BETWEEN_EPOCHS = 11644473600; 
    316271  static const __int64 SECS_TO_100NS = 10000000; 
     272  inline unsigned long long filetime_to_time(unsigned long long filetime) { 
     273    return (filetime - (SECS_BETWEEN_EPOCHS * SECS_TO_100NS)) / SECS_TO_100NS; 
     274  } 
    317275  inline std::wstring format_filetime(unsigned long long filetime, std::wstring format = _T("%Y-%m-%d %H:%M:%S")) { 
    318276    if (filetime == 0) 
    319277      return _T("ZERO"); 
    320     filetime -= (SECS_BETWEEN_EPOCHS * SECS_TO_100NS); 
    321     filetime /= SECS_TO_100NS; 
    322     return format_date(static_cast<time_t>(filetime), format); 
    323   } 
    324  
    325     int len = wcslen(string); 
    326     for (int i=0;i<len;i++) { 
    327       if (string[i] == 10 || string[i] == 13) 
    328         string[i] = L' '; 
    329     } 
    330   } 
    331   */ 
    332   static const unsigned long long SECS_BETWEEN_EPOCHS = 11644473600; 
    333   static const unsigned long long SECS_TO_100NS = 10000000; 
    334    
    335   inline std::wstring format_filetime(unsigned long long filetime, std::wstring format = _T("%Y-%m-%d %H:%M:%S")) { 
    336     filetime -= (SECS_BETWEEN_EPOCHS * SECS_TO_100NS); 
    337     filetime /= SECS_TO_100NS; 
    338     return format_date(static_cast<time_t>(filetime), format); 
     278    return format_date(static_cast<time_t>(filetime_to_time(filetime)), format); 
    339279  } 
    340280 
     
    740680  //typedef std::basic_string<char, blind_traits<char>, std::allocator<char> >  blindstr; 
    741681  typedef std::basic_string<wchar_t, blind_traits<wchar_t>, std::allocator<wchar_t> >  blindstr; 
    742 /* 
    743   class StrICmp 
    744   { 
    745   public: 
    746     StrICmp(const std::string &Lang = "english") : m_locE(Lang.c_str()) 
    747     { 
    748     } 
    749     class CharLessI 
    750     { 
    751     public: 
    752       CharLessI(std::locale &locE) : m_locE(locE) 
    753       { 
    754       } 
    755       template<typename T> 
    756       bool operator()(T c1, T c2) 
    757       { 
    758         return std::tolower(c1, m_locE) < std::tolower(c2, m_locE); 
    759       } 
    760     private: 
    761       std::locale &m_locE; 
    762     }; 
    763     template<typename T> 
    764     int operator()(const T &s1, const T &s2) 
    765     { 
    766       if (std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), CharLessI(m_locE))) 
    767         return -1; 
    768       if (std::lexicographical_compare(s2.begin(), s2.end(), s1.begin(), s1.end(), CharLessI(m_locE))) 
    769         return 1; 
    770       return 0; 
    771     } 
    772   private: 
    773     std::locale m_locE; 
    774   }; 
    775  
    776   template<typename T> 
    777   int StrCmpI(const T &s1, const T &s2, const std::string &Lang = "english") 
    778   { 
    779     return StrICmp(Lang)(s1, s2); 
    780   } 
    781  
    782   struct case_blind_string_compare : public std::binary_function<std::wstring, std::wstring, bool> 
    783   { 
    784     bool operator() (const std::wstring& x, const std::wstring& y) const { 
    785       return StrCmpI<std::wstring>(x,y) < 0; 
    786       //return _wcsicmp( x.c_str(), y.c_str() ) < 0; 
    787     } 
    788   }; 
    789   */ 
     682 
    790683 
    791684 
  • include/swap_bytes.hpp

    r40970de r1f24a1c  
    11#pragma once 
     2 
     3#include <boost/static_assert.hpp> 
    24 
    35namespace swap_bytes { 
Note: See TracChangeset for help on using the changeset viewer.