• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "link.h"
17 
18 namespace OHOS {
19 namespace UDMF {
Link()20 Link::Link() : Link("", "")
21 {
22 }
23 
Link(const std::string & url)24 Link::Link(const std::string &url) : Link(url, "")
25 {
26 }
27 
Link(const std::string & url,const std::string & description)28 Link::Link(const std::string &url, const std::string &description)
29 {
30     if (url.length() >= MAX_TEXT_LEN || description.length() >= MAX_TEXT_LEN) {
31         return;
32     }
33     this->dataType_ = HYPERLINK;
34     this->url_ = url;
35     this->description_ = description;
36 }
37 
GetSize()38 int64_t Link::GetSize()
39 {
40     return UnifiedDataUtils::GetDetailsSize(this->details_) + this->url_.size() + this->description_.size();
41 }
42 
GetUrl() const43 std::string Link::GetUrl() const
44 {
45     return this->url_;
46 }
47 
SetUrl(const std::string & url)48 void Link::SetUrl(const std::string &url)
49 {
50     if (url.length() >= MAX_TEXT_LEN) {
51         return;
52     }
53     this->url_ = url;
54 }
55 
GetDescription() const56 std::string Link::GetDescription() const
57 {
58     return this->description_;
59 }
60 
SetDescription(const std::string & description)61 void Link::SetDescription(const std::string &description)
62 {
63     if (description.length() >= MAX_TEXT_LEN) {
64         return;
65     }
66     this->description_ = description;
67 }
68 } // namespace UDMF
69 } // namespace OHOS