LCOV - code coverage report
Current view: top level - jdx/api - JdxScanner.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 6 6 100.0 %
Date: 2025-06-15 16:18:27 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* Copyright (C) 2025 Robert Schiwon
       2             :  *
       3             :  * This file is part of libjdx.
       4             :  *
       5             :  * libjdx is free software: you can redistribute it and/or modify it under the
       6             :  * terms of the GNU Lesser General Public License as published by the Free
       7             :  * Software Foundation, either version 3 of the License, or (at your option) any
       8             :  * later version.
       9             :  *
      10             :  * libjdx is distributed in the hope that it will be useful, but WITHOUT ANY
      11             :  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      12             :  * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with libjdx. If not, see <https://www.gnu.org/licenses/>.
      17             :  */
      18             : #include "jdx/api/JdxScanner.hpp"
      19             : #include "jdx/JdxParser.hpp"
      20             : #include "jdx/api/JdxConverter.hpp"
      21             : 
      22             : #include <fstream>
      23             : #include <iostream>
      24             : #include <sstream>
      25             : 
      26             : #ifdef __EMSCRIPTEN__
      27             : #include <emscripten/bind.h>
      28             : #endif
      29             : 
      30           6 : bool libjdx::jdx::api::JdxScanner::isRecognized(const std::string& path)
      31             : {
      32             :     // std::cout << "C++: JdxScanner.isRecognized(): " << path << '\n';
      33           6 :     std::ifstream input{path};
      34           6 :     auto isRecognized = libjdx::jdx::JdxParser::canParse(path, input);
      35          12 :     return isRecognized;
      36             : }
      37             : 
      38             : std::unique_ptr<libjdx::api::Converter>
      39           4 : libjdx::jdx::api::JdxScanner::getConverter(const std::string& path)
      40             : {
      41           4 :     return std::make_unique<libjdx::jdx::api::JdxConverter>(path);
      42             : }
      43             : 
      44             : #ifdef __EMSCRIPTEN__
      45             : EMSCRIPTEN_BINDINGS(JdxScanner)
      46             : {
      47             :     using namespace libjdx::api;
      48             :     using namespace libjdx::jdx::api;
      49             :     using namespace emscripten;
      50             :     class_<JdxScanner, base<Scanner>>("JdxScanner")
      51             :         .smart_ptr_constructor("JdxScanner", &std::make_shared<JdxScanner>)
      52             :         .function("isRecognized", &JdxScanner::isRecognized)
      53             :         .function("getConverter", &JdxScanner::getConverter);
      54             : }
      55             : #endif

Generated by: LCOV version 1.14