1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CPP_ABCKIT_LITERAL_IMPL_H 17 #define CPP_ABCKIT_LITERAL_IMPL_H 18 19 #include <cstdint> 20 #include "literal_array.h" 21 #include "literal.h" 22 23 namespace abckit { 24 GetBool()25inline bool Literal::GetBool() const 26 { 27 bool ret = GetApiConfig()->cIapi_->literalGetBool(GetView()); 28 CheckError(GetApiConfig()); 29 return ret; 30 } 31 GetLiteralArray()32inline abckit::LiteralArray Literal::GetLiteralArray() const 33 { 34 LiteralArray ret(GetApiConfig()->cIapi_->literalGetLiteralArray(GetView()), GetApiConfig(), GetResource()); 35 CheckError(GetApiConfig()); 36 return ret; 37 } 38 GetU8()39inline uint8_t Literal::GetU8() const 40 { 41 auto val = GetApiConfig()->cIapi_->literalGetU8(GetView()); 42 CheckError(GetApiConfig()); 43 return val; 44 } 45 GetU16()46inline uint16_t Literal::GetU16() const 47 { 48 auto val = GetApiConfig()->cIapi_->literalGetU16(GetView()); 49 CheckError(GetApiConfig()); 50 return val; 51 } 52 GetU32()53inline uint32_t Literal::GetU32() const 54 { 55 auto val = GetApiConfig()->cIapi_->literalGetU32(GetView()); 56 CheckError(GetApiConfig()); 57 return val; 58 } 59 GetU64()60inline uint64_t Literal::GetU64() const 61 { 62 auto val = GetApiConfig()->cIapi_->literalGetU64(GetView()); 63 CheckError(GetApiConfig()); 64 return val; 65 } 66 GetFloat()67inline float Literal::GetFloat() const 68 { 69 auto val = GetApiConfig()->cIapi_->literalGetFloat(GetView()); 70 CheckError(GetApiConfig()); 71 return val; 72 } 73 GetDouble()74inline double Literal::GetDouble() const 75 { 76 auto val = GetApiConfig()->cIapi_->literalGetDouble(GetView()); 77 CheckError(GetApiConfig()); 78 return val; 79 } 80 GetMethodAffiliate()81inline uint16_t Literal::GetMethodAffiliate() const 82 { 83 auto val = GetApiConfig()->cIapi_->literalGetMethodAffiliate(GetView()); 84 CheckError(GetApiConfig()); 85 return val; 86 } 87 GetString()88inline std::string Literal::GetString() const 89 { 90 auto val = GetApiConfig()->cIapi_->literalGetString(GetView()); 91 CheckError(GetApiConfig()); 92 auto str = GetApiConfig()->cIapi_->abckitStringToString(val); 93 CheckError(GetApiConfig()); 94 return str; 95 } 96 GetMethod()97inline std::string Literal::GetMethod() const 98 { 99 auto val = GetApiConfig()->cIapi_->literalGetMethod(GetView()); 100 CheckError(GetApiConfig()); 101 auto str = GetApiConfig()->cIapi_->abckitStringToString(val); 102 CheckError(GetApiConfig()); 103 return str; 104 } 105 GetTag()106inline enum AbckitLiteralTag Literal::GetTag() const 107 { 108 auto tag = GetApiConfig()->cIapi_->literalGetTag(GetView()); 109 CheckError(GetApiConfig()); 110 return tag; 111 } 112 113 } // namespace abckit 114 115 #endif // CPP_ABCKIT_LITERAL_IMPL_H 116