1 /* 2 * Copyright (c) 2023 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 #include "plain_text.h" 17 18 namespace OHOS { 19 namespace UDMF { PlainText()20PlainText::PlainText() : PlainText("", "") 21 { 22 } 23 PlainText(const std::string & content,const std::string & abstract)24PlainText::PlainText(const std::string &content, const std::string &abstract) 25 { 26 if (content.length() >= MAX_TEXT_LEN) { 27 return; 28 } 29 this->dataType_ = PLAIN_TEXT; 30 this->content_ = content; 31 this->abstract_ = abstract; 32 } 33 GetSize()34int64_t PlainText::GetSize() 35 { 36 return UnifiedDataUtils::GetDetailsSize(this->details_) + this->content_.size() + this->abstract_.size(); 37 } 38 GetContent() const39std::string PlainText::GetContent() const 40 { 41 return this->content_; 42 } 43 SetContent(const std::string & text)44void PlainText::SetContent(const std::string &text) 45 { 46 if (text.length() >= MAX_TEXT_LEN) { 47 return; 48 } 49 this->content_ = text; 50 } 51 GetAbstract() const52std::string PlainText::GetAbstract() const 53 { 54 return this->abstract_; 55 } 56 SetAbstract(const std::string & abstract)57void PlainText::SetAbstract(const std::string &abstract) 58 { 59 if (abstract.length() >= MAX_TEXT_LEN) { 60 return; 61 } 62 this->abstract_ = abstract; 63 } 64 } // namespace UDMF 65 } // namespace OHOS 66