Line data Source code
1 : /*! 2 : * \file esys/repo/manifest/kind_manifest.cpp 3 : * \brief 4 : * 5 : * \cond 6 : * __legal_b__ 7 : * 8 : * Copyright (c) 2021-2022 Michel Gillet 9 : * Distributed under the MIT License. 10 : * (See accompanying file LICENSE.txt or 11 : * copy at https://opensource.org/licenses/MIT) 12 : * 13 : * __legal_e__ 14 : * \endcond 15 : * 16 : */ 17 : 18 : #include "esys/repo/esysrepo_prec.h" 19 : #include "esys/repo/manifest/kind.h" 20 : 21 : namespace esys::repo::manifest 22 : { 23 : 24 22 : Result convert(Kind type, std::string &text) 25 : { 26 22 : switch (type) 27 : { 28 21 : case Kind::ISOLATED: text = "isolated"; break; 29 1 : case Kind::EMBEDDED: text = "embedded"; break; 30 0 : default: return ESYSREPO_RESULT(ResultCode::MANIFEST_KIND_UNKNOWN); 31 : } 32 22 : return ESYSREPO_RESULT(ResultCode::OK); 33 : } 34 : 35 41 : Result convert(const std::string &text, Kind &kind) 36 : { 37 41 : if (text == "isolated") 38 38 : kind = Kind::ISOLATED; 39 3 : else if (text == "embedded") 40 3 : kind = Kind::EMBEDDED; 41 : else 42 : { 43 0 : kind = Kind::UNKNOWN; 44 0 : return ESYSREPO_RESULT(ResultCode::MANIFEST_KIND_UNKNOWN); 45 : } 46 41 : return ESYSREPO_RESULT(ResultCode::OK); 47 : } 48 : 49 : } // namespace esys::repo::manifest