Line data Source code
1 : /*! 2 : * \file esys/repo/manifest/type_manifest.cpp 3 : * \brief 4 : * 5 : * \cond 6 : * __legal_b__ 7 : * 8 : * Copyright (c) 2020 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/type.h" 20 : #include "esys/repo/grepo/manifest.h" 21 : #include "esys/repo/manifest/base.h" 22 : 23 : namespace esys::repo::manifest 24 : { 25 : 26 22 : Result convert(Type type, std::string &text) 27 : { 28 22 : switch (type) 29 : { 30 9 : case Type::ESYSREPO_MANIFEST: text = "esysrepo"; break; 31 0 : case Type::GIT_SUPER_PROJECT: text = "git_super_project"; break; 32 13 : case Type::GOOGLE_MANIFEST: text = "grepo"; break; 33 0 : default: return ESYSREPO_RESULT(ResultCode::MANIFEST_TYPE_UNKNOWN); 34 : } 35 22 : return ESYSREPO_RESULT(ResultCode::OK); 36 : } 37 : 38 37 : Result convert(const std::string &text, Type &type) 39 : { 40 37 : if (text == manifest::Base::get_folder_name()) 41 17 : type = Type::ESYSREPO_MANIFEST; 42 20 : else if (text == "git_super_project") 43 0 : type = Type::GIT_SUPER_PROJECT; 44 20 : else if (text == grepo::Manifest::get_folder_name()) 45 20 : type = Type::GOOGLE_MANIFEST; 46 : else 47 : { 48 0 : type = Type::UNKNOWN; 49 0 : return ESYSREPO_RESULT(ResultCode::MANIFEST_TYPE_UNKNOWN); 50 : } 51 37 : return ESYSREPO_RESULT(ResultCode::OK); 52 : } 53 : 54 : } // namespace esys::repo::manifest