1 /*
2 * Copyright (c) 2021 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 "layout_header.h"
17
18 namespace OHOS::WMServer {
operator <<(std::ostream & os,const struct layout & layout)19 std::ostream &operator <<(std::ostream &os, const struct layout &layout)
20 {
21 os << layout.x << " " << layout.y << " " << layout.w << " " << layout.h;
22 return os;
23 }
24
operator <<(std::ostream & os,const enum Layout::PositionType & type)25 std::ostream &operator <<(std::ostream &os, const enum Layout::PositionType &type)
26 {
27 os << static_cast<int32_t>(type);
28 return os;
29 }
30
operator <<(std::ostream & os,const enum Layout::XPositionType & type)31 std::ostream &operator <<(std::ostream &os, const enum Layout::XPositionType &type)
32 {
33 os << static_cast<int32_t>(type);
34 return os;
35 }
36
operator <<(std::ostream & os,const enum Layout::YPositionType & type)37 std::ostream &operator <<(std::ostream &os, const enum Layout::YPositionType &type)
38 {
39 os << static_cast<int32_t>(type);
40 return os;
41 }
42
operator <<(std::ostream & os,const struct Layout & layout)43 std::ostream &operator <<(std::ostream &os, const struct Layout &layout)
44 {
45 os << std::boolalpha
46 << layout.isZIndexSetting << " " << layout.zIndex << " "
47 << layout.isPositionTypeSetting << " " << layout.positionType << " "
48 << layout.isPositionXTypeSetting << " " << layout.pTypeX << " "
49 << layout.isPositionYTypeSetting << " " << layout.pTypeY << " "
50 << layout.isLayoutSetting << " " << layout.layout;
51 return os;
52 }
53
operator >>(std::istream & is,struct layout & layout)54 std::istream &operator >>(std::istream &is, struct layout &layout)
55 {
56 is >> layout.x >> layout.y >> layout.w >> layout.h;
57 return is;
58 }
59
operator >>(std::istream & is,enum Layout::PositionType & type)60 std::istream &operator >>(std::istream &is, enum Layout::PositionType &type)
61 {
62 int32_t enumType;
63 is >> enumType;
64 type = static_cast<enum Layout::PositionType>(enumType);
65 return is;
66 }
67
operator >>(std::istream & is,enum Layout::XPositionType & type)68 std::istream &operator >>(std::istream &is, enum Layout::XPositionType &type)
69 {
70 int32_t enumType;
71 is >> enumType;
72 type = static_cast<enum Layout::XPositionType>(enumType);
73 return is;
74 }
75
operator >>(std::istream & is,enum Layout::YPositionType & type)76 std::istream &operator >>(std::istream &is, enum Layout::YPositionType &type)
77 {
78 int32_t enumType;
79 is >> enumType;
80 type = static_cast<enum Layout::YPositionType>(enumType);
81 return is;
82 }
83
operator >>(std::istream & is,struct Layout & layout)84 std::istream &operator >>(std::istream &is, struct Layout &layout)
85 {
86 is >> std::boolalpha
87 >> layout.isZIndexSetting >> layout.zIndex
88 >> layout.isPositionTypeSetting >> layout.positionType
89 >> layout.isPositionXTypeSetting >> layout.pTypeX
90 >> layout.isPositionYTypeSetting >> layout.pTypeY
91 >> layout.isLayoutSetting >> layout.layout;
92 return is;
93 }
94 } // namespace OHOS::WMServer
95