Bläddra i källkod

Changes to use ROOT w/ c++14, adds ability to specify input files w/
globbing

Caleb Fangmeier 6 år sedan
förälder
incheckning
7b00cbe8bc
2 ändrade filer med 29 tillägg och 2 borttagningar
  1. 1 1
      cmake/FindROOT.cmake
  2. 28 1
      include/config.hpp

+ 1 - 1
cmake/FindROOT.cmake

@@ -104,7 +104,7 @@ ELSE(WIN32)
     STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" ROOT_MAJOR_VER "${ROOTVERSION}")
     IF(ROOT_MAJOR_VER EQUAL 6)
       MESSAGE("-- ROOT 6 detected - requiring C++11")
-      ADD_DEFINITIONS("-std=c++1y -DROOT_MAJOR_VER=6")
+      ADD_DEFINITIONS("-std=c++14 -DROOT_MAJOR_VER=6")
     ENDIF(ROOT_MAJOR_VER EQUAL 6)
 
     # ask root-config for the library dir

+ 28 - 1
include/config.hpp

@@ -32,10 +32,14 @@
 #ifndef config_hpp
 #define config_hpp
 
+#include <cstdlib>
+#include <cstdio>
 #include <string>
 #include <fstream>
 #include <sstream>
 
+#include <regex>
+
 #include "yaml-cpp/yaml.h"
 
 namespace fv_util {
@@ -87,6 +91,22 @@ namespace YAML {
 
 namespace fv_util {
 
+
+    std::vector<std::string> glob(const std::string& base) {
+        std::stringstream ss;
+        ss << "ls -1 " << base << " > __tmp__";
+        system(ss.str().c_str());
+
+        std::vector<std::string> filenames;
+        std::ifstream f("__tmp__");
+        std::string line;
+        while (std::getline(f, line)) {
+            filenames.push_back(line);
+        }
+        std::remove("__tmp__");
+        return filenames;
+    }
+
     class Config {
     private:
         std::string input_filename;
@@ -155,7 +175,14 @@ namespace fv_util {
                 source_file_key = root["source-file-key"].as<std::string>();
             }
             YAML::Node source_files_nd = root[source_file_key];
-            if (source_files_nd.IsSequence()) {
+            if (source_files_nd.IsMap()) {
+                auto filenames = glob(source_files_nd["files"].as<std::string>());
+                DataFileDescriptor dfd;
+                for (const auto& filename : filenames) {
+                    dfd.filename = filename;
+                    source_files.push_back(dfd);
+                }
+            } else if (source_files_nd.IsSequence()) {
                 for (const auto &f : source_files_nd) {
                     source_files.push_back(f.as<DataFileDescriptor>());
                 }