1*70a7ec85SAndroid Build Coastguard Worker /* 2*70a7ec85SAndroid Build Coastguard Worker * Copyright (C) 2020 The Android Open Source Project 3*70a7ec85SAndroid Build Coastguard Worker * 4*70a7ec85SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*70a7ec85SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*70a7ec85SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*70a7ec85SAndroid Build Coastguard Worker * 8*70a7ec85SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*70a7ec85SAndroid Build Coastguard Worker * 10*70a7ec85SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*70a7ec85SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*70a7ec85SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*70a7ec85SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*70a7ec85SAndroid Build Coastguard Worker * limitations under the License. 15*70a7ec85SAndroid Build Coastguard Worker */ 16*70a7ec85SAndroid Build Coastguard Worker 17*70a7ec85SAndroid Build Coastguard Worker #pragma once 18*70a7ec85SAndroid Build Coastguard Worker 19*70a7ec85SAndroid Build Coastguard Worker #include <string> 20*70a7ec85SAndroid Build Coastguard Worker 21*70a7ec85SAndroid Build Coastguard Worker namespace android::vintf { 22*70a7ec85SAndroid Build Coastguard Worker 23*70a7ec85SAndroid Build Coastguard Worker // WithFileName is a class that attaches a name to an object. 24*70a7ec85SAndroid Build Coastguard Worker // The name is often the file name or path of the source file where the object 25*70a7ec85SAndroid Build Coastguard Worker // is deserialized from. The name is used for informational and debugging 26*70a7ec85SAndroid Build Coastguard Worker // purposes. It is not retained when the object is serialized. 27*70a7ec85SAndroid Build Coastguard Worker // It is not meant to be used as an identifier of the object: 28*70a7ec85SAndroid Build Coastguard Worker // - there may be duplicated names; 29*70a7ec85SAndroid Build Coastguard Worker // - name may be empty. 30*70a7ec85SAndroid Build Coastguard Worker struct WithFileName { 31*70a7ec85SAndroid Build Coastguard Worker WithFileName() = default; WithFileNameWithFileName32*70a7ec85SAndroid Build Coastguard Worker WithFileName(const std::string& fileName) : mFileName(fileName) {} fileNameWithFileName33*70a7ec85SAndroid Build Coastguard Worker const std::string& fileName() const { return mFileName; } setFileNameWithFileName34*70a7ec85SAndroid Build Coastguard Worker void setFileName(std::string&& fileName) { mFileName = std::move(fileName); } setFileNameWithFileName35*70a7ec85SAndroid Build Coastguard Worker void setFileName(const std::string& fileName) { mFileName = fileName; } 36*70a7ec85SAndroid Build Coastguard Worker 37*70a7ec85SAndroid Build Coastguard Worker private: 38*70a7ec85SAndroid Build Coastguard Worker std::string mFileName; 39*70a7ec85SAndroid Build Coastguard Worker }; 40*70a7ec85SAndroid Build Coastguard Worker 41*70a7ec85SAndroid Build Coastguard Worker } // namespace android::vintf 42