![]() |
|
|||
File indexing completed on 2025-09-17 09:07:47
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file orange/detail/LogicUtils.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <iostream> 0010 #include <vector> 0011 0012 #include "corecel/Assert.hh" 0013 #include "corecel/cont/Span.hh" 0014 #include "corecel/io/Join.hh" 0015 0016 #include "../OrangeTypes.hh" 0017 0018 namespace celeritas 0019 { 0020 namespace detail 0021 { 0022 //---------------------------------------------------------------------------// 0023 /*! 0024 * Convert a logic token to a string. 0025 */ 0026 inline void logic_to_stream(std::ostream& os, logic_int val) 0027 { 0028 if (logic::is_operator_token(val)) 0029 { 0030 os << to_char(static_cast<logic::OperatorToken>(val)); 0031 } 0032 else 0033 { 0034 // Just a face ID 0035 os << val; 0036 } 0037 } 0038 0039 //---------------------------------------------------------------------------// 0040 /*! 0041 * Convert a logic vector to a string. 0042 */ 0043 inline std::string logic_to_string(std::vector<logic_int> const& logic) 0044 { 0045 return to_string(celeritas::join_stream( 0046 logic.begin(), logic.end(), ' ', logic_to_stream)); 0047 } 0048 0049 //---------------------------------------------------------------------------// 0050 /*! 0051 * Convert a postfix logic expression to an infix expression. 0052 */ 0053 std::vector<logic_int> convert_to_infix(Span<logic_int const> postfix); 0054 0055 //---------------------------------------------------------------------------// 0056 /*! 0057 * Build a logic definition from a C string. 0058 */ 0059 std::vector<logic_int> string_to_logic(std::string const& s); 0060 0061 //---------------------------------------------------------------------------// 0062 } // namespace detail 0063 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |