LCOV - code coverage report
Current view: top level - utilites/matchmaker/matcher - builder.cpp (source / functions) Hit Total Coverage
Test: wfc_jsonrpc-coverage.info Lines: 23 23 100.0 %
Date: 2019-09-12 Functions: 5 5 100.0 %

          Line data    Source code
       1             : 
       2             : #include "builder.hpp"
       3             : #include "true_match.hpp"
       4             : #include "array_match.hpp"
       5             : #include "variant_match.hpp"
       6             : #include "object_match.hpp"
       7             : 
       8             : namespace wfc{ namespace jsonrpc{ 
       9             : 
      10          56 : builder::builder(int mode)
      11          56 :   : _factory(mode)
      12          56 : {}
      13             : 
      14         112 : std::shared_ptr<imatcher> builder::build_name()
      15             : {
      16         112 :   return _factory.create_name();
      17             : }
      18             : 
      19         193 : std::shared_ptr<imatcher> builder::build_value(const char* beg, const char* end, json::json_error& err)
      20             : {
      21         193 :   return this->build_value_(beg, end, err, false);
      22             : }
      23             :   
      24          32 : std::shared_ptr<imatcher> builder::build_value_nv(const char* beg, const char* end, json::json_error& err)
      25             : {
      26          32 :   return this->build_value_(beg, end, err, true);
      27             : }
      28             : 
      29         225 : std::shared_ptr<imatcher> builder::build_value_(const char* beg, const char* end, json::json_error& err, bool nv) 
      30             : {
      31         225 :   beg = json::parser::parse_space(beg, end, &err);
      32         225 :   if (err || beg==end) return nullptr;
      33             :   
      34         225 :   std::shared_ptr<imatcher> ptr;
      35         225 :   if ( json::parser::is_null(beg, end) )
      36             :   {
      37           3 :     ptr = std::make_shared<true_match>();
      38             :   }
      39         222 :   else if ( json::parser::is_array(beg, end) )
      40             :   {
      41          29 :     if ( nv )
      42             :     {
      43          11 :       ptr = std::make_shared<array_match>( this->shared_from_this() );
      44             :     }
      45             :     else
      46             :     {
      47          18 :       ptr = std::make_shared<variant_match>( this->shared_from_this() );
      48             :     }
      49             :   }
      50         193 :   else if ( json::parser::is_object(beg, end) )
      51             :   {
      52          66 :     ptr = std::make_shared<object_match>( this->shared_from_this() );
      53             :   }
      54             :   else
      55             :   {
      56         127 :     ptr = _factory.create_value();
      57             :   }
      58         225 :   return ptr;
      59             : }
      60             : 
      61             : }}

Generated by: LCOV version 1.10