A MetaDynamics Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | List of all members
SSAGES::IncludePlugin Class Reference

Class for JSON loader include plugin. More...

#include <JSONLoaderPlugin.h>

Inheritance diagram for SSAGES::IncludePlugin:
Inheritance graph

Public Member Functions

virtual void ApplyFilter (std::string &contents, const std::string &path) override
 Apply filter to string. More...

Detailed Description

Class for JSON loader include plugin.

Definition at line 55 of file JSONLoaderPlugin.h.

Member Function Documentation

virtual void SSAGES::IncludePlugin::ApplyFilter ( std::string &  contents,
const std::string &  path 

Apply filter to string.

contentsString whose contents will be modified.
pathPath for JSON path specification.

This filter replaces @include(file.json) with contents.

Implements SSAGES::JSONLoaderPlugin.

Definition at line 66 of file JSONLoaderPlugin.h.

References SSAGES::GetFileContents().

67  {
68  std::smatch matches;
69  auto pattern = std::regex("\"@include\\((.*)\\)\"", std::regex::ECMAScript);
70  while(regex_search(contents, matches, pattern))
71  {
72  for(size_t i = 1; i < matches.size(); ++i)
73  {
74  auto content = GetFileContents((path + "/" + matches[i].str()).c_str());
75  auto rpattern = std::regex("\"@include\\(" +
76  matches[i].str() +
77  "\\)\"", std::regex::ECMAScript);
78  contents = regex_replace(contents, rpattern, content);
79  }
80  }
81  }
std::string GetFileContents(const char *filename)
Read contents from a file.
Definition: FileContents.h:47

Here is the call graph for this function:

The documentation for this class was generated from the following file: