File indexing completed on 2024-05-19 05:42:10

0001 // ct_lvtmdb_functionbase.cpp                                         -*-C++-*-
0002 
0003 /*
0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk>
0005 // SPDX-License-Identifier: Apache-2.0
0006 //
0007 // Licensed under the Apache License, Version 2.0 (the "License");
0008 // you may not use this file except in compliance with the License.
0009 // You may obtain a copy of the License at
0010 //
0011 //     http://www.apache.org/licenses/LICENSE-2.0
0012 //
0013 // Unless required by applicable law or agreed to in writing, software
0014 // distributed under the License is distributed on an "AS IS" BASIS,
0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016 // See the License for the specific language governing permissions and
0017 // limitations under the License.
0018 */
0019 
0020 #include <ct_lvtmdb_functionbase.h>
0021 
0022 namespace Codethink::lvtmdb {
0023 
0024 FunctionBase::FunctionBase(std::string qualifiedName,
0025                            std::string name,
0026                            std::string signature,
0027                            std::string returnType,
0028                            std::string templateParameters):
0029     DatabaseObject(std::move(qualifiedName), std::move(name)),
0030     d_signature(std::move(signature)),
0031     d_returnType(std::move(returnType)),
0032     d_templateParameters(std::move(templateParameters))
0033 {
0034 }
0035 
0036 FunctionBase::~FunctionBase() noexcept = default;
0037 
0038 FunctionBase::FunctionBase(FunctionBase&&) noexcept = default;
0039 
0040 FunctionBase& FunctionBase::operator=(FunctionBase&&) noexcept = default;
0041 
0042 const std::string& FunctionBase::signature() const
0043 {
0044     assertReadable();
0045     return d_signature;
0046 }
0047 
0048 const std::string& FunctionBase::returnType() const
0049 {
0050     assertReadable();
0051     return d_returnType;
0052 }
0053 
0054 const std::string& FunctionBase::templateParameters() const
0055 {
0056     assertReadable();
0057     return d_templateParameters;
0058 }
0059 
0060 std::string FunctionBase::storageKey() const
0061 {
0062     assertReadable();
0063     return getStorageKey(qualifiedName(), d_signature, d_templateParameters, d_returnType);
0064 }
0065 
0066 std::string FunctionBase::getStorageKey(const std::string& qualifiedName,
0067                                         const std::string& signature,
0068                                         const std::string& templateParameters,
0069                                         const std::string& returnType)
0070 {
0071     return qualifiedName + '\n' + signature + '\n' + templateParameters + '\n' + returnType;
0072 }
0073 
0074 } // namespace Codethink::lvtmdb