NEML2 1.4.0
Loading...
Searching...
No Matches
Parser.cxx
1// Copyright 2023, UChicago Argonne, LLC
2// All Rights Reserved
3// Software Name: NEML2 -- the New Engineering material Model Library, version 2
4// By: Argonne National Laboratory
5// OPEN SOURCE LICENSE (MIT)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24
25#include "neml2/base/Parser.h"
26#include "neml2/base/Factory.h"
27#include "neml2/base/HITParser.h"
28
29namespace neml2
30{
31void
32load_model(const std::string & path, const std::string & additional_input, ParserType ptype)
33{
34 // We are being forward looking here
36 {
37 if (utils::end_with(path, ".i"))
39 else if (utils::end_with(path, ".xml"))
41 else if (utils::end_with(path, ".yml"))
43 }
44
45 // but for now we only support HIT
47 {
49
52 }
53 else
54 neml_assert(false, "Unsupported parser type");
55}
56} // namespace neml2
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
static void load(const OptionCollection &all_options)
Provide all objects' options to the factory. The factory is ready to manufacture objects after this c...
Definition Factory.cxx:39
static void clear()
Destruct all the objects.
Definition Factory.cxx:73
A parser is responsible for parsing an input file into a collection of options which can be used by t...
Definition HITParser.h:37
bool end_with(std::string_view str, std::string_view suffix)
Definition parser_utils.cxx:92
Definition CrossRef.cxx:32
ParserType
Definition Parser.h:33
@ XML
Definition Parser.h:35
@ YAML
Definition Parser.h:36
@ HIT
Definition Parser.h:34
@ AUTO
Definition Parser.h:37
void load_model(const std::string &path, const std::string &additional_input, ParserType ptype)
A convenient function to parse all options from an input file.
Definition Parser.cxx:32
void neml_assert(bool assertion, Args &&... args)
Definition error.h:73