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 "attr_data.h"
17 #include <cstdint>
18 #include <memory>
19 #include <utility>
20 #include <functional>
21 #include "__tree"
22 #include "cstdint"
23 #include "image_log.h"
24 #include "iosfwd"
25 #include "iterator"
26 #include "new"
27 #include "plugin_errors.h"
28 #ifndef _WIN32
29 #include "securec.h"
30 #else
31 #include "memory.h"
32 #endif
33 #include "set"
34 #include "string"
35 #include "type_traits"
36
37 #undef LOG_DOMAIN
38 #define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN
39
40 #undef LOG_TAG
41 #define LOG_TAG "AttrData"
42
43 namespace OHOS {
44 namespace MultimediaPlugin {
45 using std::set;
46 using std::string;
47
AttrData()48 AttrData::AttrData() : type_(AttrDataType::ATTR_DATA_NULL)
49 {}
50
AttrData(bool value)51 AttrData::AttrData(bool value) : type_(AttrDataType::ATTR_DATA_BOOL)
52 {
53 value_.boolValue = value;
54 }
55
AttrData(uint32_t value)56 AttrData::AttrData(uint32_t value) : type_(AttrDataType::ATTR_DATA_UINT32)
57 {
58 value_.uint32Value = value;
59 }
60
AttrData(const string & value)61 AttrData::AttrData(const string &value) : type_(AttrDataType::ATTR_DATA_STRING)
62 {
63 value_.stringValue = new (std::nothrow) string(value);
64 if (value_.stringValue == nullptr) {
65 IMAGE_LOGE("AttrData: alloc stringValue result null!");
66 type_ = AttrDataType::ATTR_DATA_NULL;
67 }
68 }
69
AttrData(string && value)70 AttrData::AttrData(string &&value) : type_(AttrDataType::ATTR_DATA_STRING)
71 {
72 value_.stringValue = new (std::nothrow) string(std::move(value));
73 if (value_.stringValue == nullptr) {
74 IMAGE_LOGE("AttrData: alloc stringValue result null!");
75 type_ = AttrDataType::ATTR_DATA_NULL;
76 }
77 }
78
AttrData(uint32_t lowerBound,uint32_t upperBound)79 AttrData::AttrData(uint32_t lowerBound, uint32_t upperBound) : type_(AttrDataType::ATTR_DATA_UINT32_RANGE)
80 {
81 if (lowerBound > upperBound) {
82 type_ = AttrDataType::ATTR_DATA_NULL;
83 }
84
85 value_.uint32Rang[LOWER_BOUND_INDEX] = lowerBound;
86 value_.uint32Rang[UPPER_BOUND_INDEX] = upperBound;
87 }
88
AttrData(const AttrData & data)89 AttrData::AttrData(const AttrData &data)
90 {
91 switch (data.type_) {
92 case AttrDataType::ATTR_DATA_BOOL: {
93 value_.boolValue = data.value_.boolValue;
94 type_ = AttrDataType::ATTR_DATA_BOOL;
95 break;
96 }
97 case AttrDataType::ATTR_DATA_UINT32: {
98 value_.uint32Value = data.value_.uint32Value;
99 type_ = AttrDataType::ATTR_DATA_UINT32;
100 break;
101 }
102 case AttrDataType::ATTR_DATA_STRING: {
103 (void)InitStringAttrData(data);
104 break;
105 }
106 case AttrDataType::ATTR_DATA_UINT32_SET: {
107 (void)InitUint32SetAttrData(data);
108 break;
109 }
110 case AttrDataType::ATTR_DATA_STRING_SET: {
111 (void)InitStringSetAttrData(data);
112 break;
113 }
114 case AttrDataType::ATTR_DATA_UINT32_RANGE: {
115 value_.uint32Rang[LOWER_BOUND_INDEX] = data.value_.uint32Rang[LOWER_BOUND_INDEX];
116 value_.uint32Rang[UPPER_BOUND_INDEX] = data.value_.uint32Rang[UPPER_BOUND_INDEX];
117 type_ = AttrDataType::ATTR_DATA_UINT32_RANGE;
118 break;
119 }
120 default: {
121 IMAGE_LOGD("AttrData: null or unexpected type in copy constructor: %{public}d.", data.type_);
122 type_ = AttrDataType::ATTR_DATA_NULL;
123 }
124 }
125 }
126
AttrData(AttrData && data)127 AttrData::AttrData(AttrData &&data) noexcept
128 {
129 if (memcpy_s(&value_, sizeof(value_), &data.value_, sizeof(data.value_)) == EOK) {
130 type_ = data.type_;
131 data.type_ = AttrDataType::ATTR_DATA_NULL;
132 } else {
133 type_ = AttrDataType::ATTR_DATA_NULL;
134 IMAGE_LOGE("memcpy error in assignment operator!");
135 }
136 }
137
~AttrData()138 AttrData::~AttrData()
139 {
140 ClearData();
141 }
142
operator =(const AttrData & data)143 AttrData &AttrData::operator=(const AttrData &data)
144 {
145 // make a copy, avoid self-assignment problems.
146 AttrData temp(data);
147 ClearData();
148 if (memcpy_s(&value_, sizeof(value_), &temp.value_, sizeof(temp.value_)) == 0) {
149 type_ = temp.type_;
150 temp.type_ = AttrDataType::ATTR_DATA_NULL;
151 } else {
152 type_ = AttrDataType::ATTR_DATA_NULL;
153 IMAGE_LOGE("memcpy error in assignment operator!");
154 }
155
156 return *this;
157 }
158
operator =(AttrData && data)159 AttrData &AttrData::operator=(AttrData &&data) noexcept
160 {
161 // case if self-assignment.
162 if (&data == this) {
163 return *this;
164 }
165
166 ClearData();
167 if (memcpy_s(&value_, sizeof(value_), &data.value_, sizeof(data.value_)) == EOK) {
168 type_ = data.type_;
169 data.type_ = AttrDataType::ATTR_DATA_NULL;
170 } else {
171 type_ = AttrDataType::ATTR_DATA_NULL;
172 IMAGE_LOGE("memcpy error in assignment operator!");
173 }
174
175 return *this;
176 }
177
SetData(bool value)178 void AttrData::SetData(bool value)
179 {
180 ClearData();
181 value_.boolValue = value;
182 type_ = AttrDataType::ATTR_DATA_BOOL;
183 }
184
SetData(uint32_t value)185 void AttrData::SetData(uint32_t value)
186 {
187 ClearData();
188 value_.uint32Value = value;
189 type_ = AttrDataType::ATTR_DATA_UINT32;
190 }
191
SetData(const string & value)192 uint32_t AttrData::SetData(const string &value)
193 {
194 if (type_ == AttrDataType::ATTR_DATA_STRING) {
195 *(value_.stringValue) = value;
196 return SUCCESS;
197 }
198
199 string *newValue = new (std::nothrow) string(value);
200 if (newValue == nullptr) {
201 IMAGE_LOGE("SetData: alloc string result null!");
202 return ERR_INTERNAL;
203 }
204
205 ClearData();
206 value_.stringValue = newValue;
207 type_ = AttrDataType::ATTR_DATA_STRING;
208 return SUCCESS;
209 }
210
SetData(string && value)211 uint32_t AttrData::SetData(string &&value)
212 {
213 if (type_ == AttrDataType::ATTR_DATA_STRING) {
214 *(value_.stringValue) = std::move(value);
215 return SUCCESS;
216 }
217
218 string *newValue = new (std::nothrow) string(std::move(value));
219 if (newValue == nullptr) {
220 IMAGE_LOGE("SetData: alloc string result null!");
221 return ERR_INTERNAL;
222 }
223
224 ClearData();
225 value_.stringValue = newValue;
226 type_ = AttrDataType::ATTR_DATA_STRING;
227 return SUCCESS;
228 }
229
SetData(uint32_t lowerBound,uint32_t upperBound)230 uint32_t AttrData::SetData(uint32_t lowerBound, uint32_t upperBound)
231 {
232 if (lowerBound > upperBound) {
233 IMAGE_LOGE("SetData: lowerBound is upper than upperBound, lower: %{public}u, upper: %{public}u.",
234 lowerBound, upperBound);
235 return ERR_INVALID_PARAMETER;
236 }
237
238 ClearData();
239 value_.uint32Rang[LOWER_BOUND_INDEX] = lowerBound;
240 value_.uint32Rang[UPPER_BOUND_INDEX] = upperBound;
241 type_ = AttrDataType::ATTR_DATA_UINT32_RANGE;
242 return SUCCESS;
243 }
244
ClearData()245 void AttrData::ClearData()
246 {
247 switch (type_) {
248 case AttrDataType::ATTR_DATA_STRING: {
249 if (value_.stringValue != nullptr) {
250 delete value_.stringValue;
251 value_.stringValue = nullptr;
252 }
253 break;
254 }
255 case AttrDataType::ATTR_DATA_UINT32_SET: {
256 if (value_.uint32Set != nullptr) {
257 delete value_.uint32Set;
258 value_.uint32Set = nullptr;
259 }
260 break;
261 }
262 case AttrDataType::ATTR_DATA_STRING_SET: {
263 if (value_.stringSet != nullptr) {
264 delete value_.stringSet;
265 value_.stringSet = nullptr;
266 }
267 break;
268 }
269 default: {
270 // do nothing
271 IMAGE_LOGD("ClearData: do nothing for type %{public}d.", type_);
272 break;
273 }
274 }
275
276 type_ = AttrDataType::ATTR_DATA_NULL;
277 }
278
InsertSet(uint32_t value)279 uint32_t AttrData::InsertSet(uint32_t value)
280 {
281 if (type_ == AttrDataType::ATTR_DATA_NULL) {
282 value_.uint32Set = new (std::nothrow) set<uint32_t>({ value });
283 if (value_.uint32Set == nullptr) {
284 IMAGE_LOGE("InsertSet: alloc uint32Set result null!");
285 return ERR_INTERNAL;
286 }
287
288 type_ = AttrDataType::ATTR_DATA_UINT32_SET;
289 return SUCCESS;
290 }
291
292 if (type_ != AttrDataType::ATTR_DATA_UINT32_SET) {
293 IMAGE_LOGE("InsertSet: AttrData type is not uint32Set or null, type: %{public}d.", type_);
294 return ERR_UNSUPPORTED;
295 }
296
297 auto result = value_.uint32Set->insert(value);
298 if (!result.second) {
299 IMAGE_LOGE("InsertSet: set insert error!");
300 return ERR_GENERAL;
301 }
302
303 return SUCCESS;
304 }
305
InsertSet(const string & value)306 uint32_t AttrData::InsertSet(const string &value)
307 {
308 if (type_ == AttrDataType::ATTR_DATA_NULL) {
309 value_.stringSet = new (std::nothrow) set<string>({ value });
310 if (value_.stringSet == nullptr) {
311 IMAGE_LOGE("InsertSet: alloc stringSet result null!");
312 return ERR_INTERNAL;
313 }
314
315 type_ = AttrDataType::ATTR_DATA_STRING_SET;
316 return SUCCESS;
317 }
318
319 if (type_ != AttrDataType::ATTR_DATA_STRING_SET) {
320 IMAGE_LOGE("InsertSet: AttrData type is not stringSet or null, type: %{public}d.", type_);
321 return ERR_UNSUPPORTED;
322 }
323
324 auto result = value_.stringSet->insert(value);
325 if (!result.second) {
326 IMAGE_LOGE("InsertSet: set insert error!");
327 return ERR_INTERNAL;
328 }
329
330 return SUCCESS;
331 }
332
InsertSet(string && value)333 uint32_t AttrData::InsertSet(string &&value)
334 {
335 if (type_ == AttrDataType::ATTR_DATA_NULL) {
336 value_.stringSet = new (std::nothrow) set<string>;
337 if (value_.stringSet == nullptr) {
338 IMAGE_LOGE("InsertSet: alloc stringSet result null!");
339 return ERR_INTERNAL;
340 }
341
342 auto result = value_.stringSet->insert(std::move(value));
343 if (!result.second) {
344 delete value_.stringSet;
345 value_.stringSet = nullptr;
346 IMAGE_LOGE("InsertSet: set insert error!");
347 return ERR_INTERNAL;
348 }
349
350 type_ = AttrDataType::ATTR_DATA_STRING_SET;
351 return SUCCESS;
352 }
353
354 if (type_ != AttrDataType::ATTR_DATA_STRING_SET) {
355 IMAGE_LOGE("InsertSet: AttrData type is not stringSet or null, type: %{public}d.", type_);
356 return ERR_UNSUPPORTED;
357 }
358
359 auto result = value_.stringSet->insert(std::move(value));
360 if (!result.second) {
361 IMAGE_LOGE("InsertSet: set insert error!");
362 return ERR_INTERNAL;
363 }
364
365 return SUCCESS;
366 }
367
InRange(bool value) const368 bool AttrData::InRange(bool value) const
369 {
370 if (type_ != AttrDataType::ATTR_DATA_BOOL) {
371 IMAGE_LOGE("InRange: comparison of bool type with non-bool type: %{public}d.", type_);
372 return false;
373 }
374
375 return value == value_.boolValue;
376 }
377
InRange(uint32_t value) const378 bool AttrData::InRange(uint32_t value) const
379 {
380 switch (type_) {
381 case AttrDataType::ATTR_DATA_UINT32: {
382 return value == value_.uint32Value;
383 }
384 case AttrDataType::ATTR_DATA_UINT32_SET: {
385 return value_.uint32Set->find(value) != value_.uint32Set->end();
386 }
387 case AttrDataType::ATTR_DATA_UINT32_RANGE: {
388 return InRangeUint32Range(value);
389 }
390 default: {
391 IMAGE_LOGE("InRange: comparison of uint32 type with non-uint32 type: %{public}d.", type_);
392 return false;
393 }
394 }
395 }
396
InRange(const string & value) const397 bool AttrData::InRange(const string &value) const
398 {
399 switch (type_) {
400 case AttrDataType::ATTR_DATA_STRING: {
401 return value == *(value_.stringValue);
402 }
403 case AttrDataType::ATTR_DATA_STRING_SET: {
404 return value_.stringSet->find(value) != value_.stringSet->end();
405 }
406 default: {
407 IMAGE_LOGE("InRange: comparison of string type with non-string type: %{public}d.", type_);
408 return false;
409 }
410 }
411 }
412
InRange(const AttrData & data) const413 bool AttrData::InRange(const AttrData &data) const
414 {
415 switch (data.type_) {
416 case AttrDataType::ATTR_DATA_NULL: {
417 return type_ == AttrDataType::ATTR_DATA_NULL;
418 }
419 case AttrDataType::ATTR_DATA_BOOL: {
420 return InRange(data.value_.boolValue);
421 }
422 case AttrDataType::ATTR_DATA_UINT32: {
423 return InRange(data.value_.uint32Value);
424 }
425 case AttrDataType::ATTR_DATA_STRING: {
426 return InRange(*(data.value_.stringValue));
427 }
428 case AttrDataType::ATTR_DATA_UINT32_SET: {
429 return InRange(*(data.value_.uint32Set));
430 }
431 case AttrDataType::ATTR_DATA_STRING_SET: {
432 return InRange(*(data.value_.stringSet));
433 }
434 case AttrDataType::ATTR_DATA_UINT32_RANGE: {
435 return InRange(data.value_.uint32Rang);
436 }
437 default: {
438 IMAGE_LOGE("InRange: unexpected AttrData type: %{public}d.", data.type_);
439 return false;
440 }
441 }
442 }
443
GetType() const444 AttrDataType AttrData::GetType() const
445 {
446 return type_;
447 }
448
GetMinValue(uint32_t & value) const449 uint32_t AttrData::GetMinValue(uint32_t &value) const
450 {
451 switch (type_) {
452 case AttrDataType::ATTR_DATA_UINT32: {
453 value = value_.uint32Value;
454 return SUCCESS;
455 }
456 case AttrDataType::ATTR_DATA_UINT32_SET: {
457 auto iter = value_.uint32Set->begin();
458 if (iter == value_.uint32Set->end()) {
459 IMAGE_LOGE("GetMinValue: uint32Set is empty.");
460 return ERR_GENERAL;
461 }
462 value = *iter;
463 return SUCCESS;
464 }
465 case AttrDataType::ATTR_DATA_UINT32_RANGE: {
466 value = value_.uint32Rang[LOWER_BOUND_INDEX];
467 return SUCCESS;
468 }
469 default: {
470 IMAGE_LOGE("GetMinValue: invalid data type for uint32: %{public}d.", type_);
471 return ERR_INVALID_PARAMETER;
472 }
473 }
474 }
475
GetMaxValue(uint32_t & value) const476 uint32_t AttrData::GetMaxValue(uint32_t &value) const
477 {
478 switch (type_) {
479 case AttrDataType::ATTR_DATA_UINT32: {
480 value = value_.uint32Value;
481 return SUCCESS;
482 }
483 case AttrDataType::ATTR_DATA_UINT32_SET: {
484 auto iter = value_.uint32Set->rbegin();
485 if (iter == value_.uint32Set->rend()) {
486 IMAGE_LOGE("GetMaxValue: GetMaxValue: uint32Set is empty.");
487 return ERR_GENERAL;
488 }
489
490 value = *iter;
491 return SUCCESS;
492 }
493 case AttrDataType::ATTR_DATA_UINT32_RANGE: {
494 value = value_.uint32Rang[UPPER_BOUND_INDEX];
495 return SUCCESS;
496 }
497 default: {
498 IMAGE_LOGE("GetMaxValue: invalid data type for uint32: %{public}d.", type_);
499 return ERR_INVALID_PARAMETER;
500 }
501 }
502 }
503
GetMinValue(const string * & value) const504 uint32_t AttrData::GetMinValue(const string *&value) const
505 {
506 switch (type_) {
507 case AttrDataType::ATTR_DATA_STRING: {
508 value = value_.stringValue;
509 return SUCCESS;
510 }
511 case AttrDataType::ATTR_DATA_STRING_SET: {
512 auto iter = value_.stringSet->begin();
513 if (iter == value_.stringSet->end()) {
514 IMAGE_LOGE("GetMinValue: stringSet is empty.");
515 return ERR_GENERAL;
516 }
517
518 value = (&(*iter));
519 return SUCCESS;
520 }
521 default: {
522 IMAGE_LOGE("GetMinValue: invalid data type for string: %{public}d.", type_);
523 return ERR_INVALID_PARAMETER;
524 }
525 }
526 }
527
GetMaxValue(const string * & value) const528 uint32_t AttrData::GetMaxValue(const string *&value) const
529 {
530 switch (type_) {
531 case AttrDataType::ATTR_DATA_STRING: {
532 value = value_.stringValue;
533 return SUCCESS;
534 }
535 case AttrDataType::ATTR_DATA_STRING_SET: {
536 auto iter = value_.stringSet->rbegin();
537 if (iter == value_.stringSet->rend()) {
538 IMAGE_LOGE("GetMaxValue: stringSet is empty.");
539 return ERR_GENERAL;
540 }
541
542 value = (&(*iter));
543 return SUCCESS;
544 }
545 default: {
546 IMAGE_LOGE("GetMaxValue: invalid data type for string: %{public}d.", type_);
547 return ERR_INVALID_PARAMETER;
548 }
549 }
550 }
551
GetValue(bool & value) const552 uint32_t AttrData::GetValue(bool &value) const
553 {
554 if (type_ != AttrDataType::ATTR_DATA_BOOL) {
555 IMAGE_LOGE("Get uint32 value: not a bool AttrData type: %{public}d.", type_);
556 return ERR_INVALID_PARAMETER;
557 }
558
559 value = value_.boolValue;
560 return SUCCESS;
561 }
562
GetValue(uint32_t & value) const563 uint32_t AttrData::GetValue(uint32_t &value) const
564 {
565 if (type_ != AttrDataType::ATTR_DATA_UINT32) {
566 IMAGE_LOGE("Get uint32 value: not a uint32 AttrData type: %{public}d.", type_);
567 return ERR_INVALID_PARAMETER;
568 }
569
570 value = value_.uint32Value;
571 return SUCCESS;
572 }
573
GetValue(string & value) const574 uint32_t AttrData::GetValue(string &value) const
575 {
576 if (type_ != AttrDataType::ATTR_DATA_STRING) {
577 IMAGE_LOGE("Get string value by reference: not a string AttrData type: %{public}d.", type_);
578 return ERR_INVALID_PARAMETER;
579 }
580
581 value = *(value_.stringValue);
582 return SUCCESS;
583 }
584
GetValue(const string * & value) const585 uint32_t AttrData::GetValue(const string *&value) const
586 {
587 if (type_ != AttrDataType::ATTR_DATA_STRING) {
588 IMAGE_LOGE("Get string value: not a string AttrData type: %{public}d.", type_);
589 return ERR_INVALID_PARAMETER;
590 }
591
592 value = value_.stringValue;
593 return SUCCESS;
594 }
595
596 // ------------------------------- private method -------------------------------
InitStringAttrData(const AttrData & data)597 uint32_t AttrData::InitStringAttrData(const AttrData &data)
598 {
599 value_.stringValue = new (std::nothrow) string(*(data.value_.stringValue));
600 if (value_.stringValue == nullptr) {
601 IMAGE_LOGE("InitStringAttrData: alloc stringValue result null!");
602 type_ = AttrDataType::ATTR_DATA_NULL;
603 return ERR_INTERNAL;
604 }
605 type_ = AttrDataType::ATTR_DATA_STRING;
606 return SUCCESS;
607 }
608
InitUint32SetAttrData(const AttrData & data)609 uint32_t AttrData::InitUint32SetAttrData(const AttrData &data)
610 {
611 value_.uint32Set = new (std::nothrow) set<uint32_t>(*(data.value_.uint32Set));
612 if (value_.uint32Set == nullptr) {
613 IMAGE_LOGE("InitUint32SetAttrData: alloc uint32Set result null!");
614 type_ = AttrDataType::ATTR_DATA_NULL;
615 return ERR_INTERNAL;
616 }
617 type_ = AttrDataType::ATTR_DATA_UINT32_SET;
618 return SUCCESS;
619 }
620
InitStringSetAttrData(const AttrData & data)621 uint32_t AttrData::InitStringSetAttrData(const AttrData &data)
622 {
623 value_.stringSet = new (std::nothrow) set<string>(*(data.value_.stringSet));
624 if (value_.stringSet == nullptr) {
625 IMAGE_LOGE("InitStringSetAttrData: alloc stringSet result null!");
626 type_ = AttrDataType::ATTR_DATA_NULL;
627 return ERR_INTERNAL;
628 }
629 type_ = AttrDataType::ATTR_DATA_STRING_SET;
630 return SUCCESS;
631 }
632
InRangeUint32Range(uint32_t value) const633 bool AttrData::InRangeUint32Range(uint32_t value) const
634 {
635 return value >= value_.uint32Rang[LOWER_BOUND_INDEX] && value <= value_.uint32Rang[UPPER_BOUND_INDEX];
636 }
637
InRange(const set<uint32_t> & uint32Set) const638 bool AttrData::InRange(const set<uint32_t> &uint32Set) const
639 {
640 if (uint32Set.empty()) {
641 return false;
642 }
643
644 for (uint32_t value : uint32Set) {
645 if (!InRange(value)) {
646 return false;
647 }
648 }
649
650 return true;
651 }
652
InRange(const set<string> & stringSet) const653 bool AttrData::InRange(const set<string> &stringSet) const
654 {
655 if (stringSet.empty()) {
656 IMAGE_LOGD("InRange: empty set of parameter.");
657 return false;
658 }
659
660 for (const string &value : stringSet) {
661 if (!InRange(value)) {
662 return false;
663 }
664 }
665
666 return true;
667 }
668
InRange(const uint32_t (& uint32Rang)[RANGE_ARRAY_SIZE]) const669 bool AttrData::InRange(const uint32_t (&uint32Rang)[RANGE_ARRAY_SIZE]) const
670 {
671 if (uint32Rang[LOWER_BOUND_INDEX] > uint32Rang[UPPER_BOUND_INDEX]) {
672 return false;
673 }
674
675 switch (type_) {
676 case AttrDataType::ATTR_DATA_UINT32: {
677 return uint32Rang[LOWER_BOUND_INDEX] == uint32Rang[UPPER_BOUND_INDEX] &&
678 uint32Rang[UPPER_BOUND_INDEX] == value_.uint32Value;
679 }
680 case AttrDataType::ATTR_DATA_UINT32_SET: {
681 auto lowerIter = value_.uint32Set->find(uint32Rang[LOWER_BOUND_INDEX]);
682 if (lowerIter == value_.uint32Set->end()) {
683 return false;
684 }
685
686 auto upperIter = value_.uint32Set->find(uint32Rang[UPPER_BOUND_INDEX]);
687 if (upperIter == value_.uint32Set->end()) {
688 return false;
689 }
690
691 uint32_t count = 0;
692 for (auto tmpIter = lowerIter; tmpIter != upperIter; ++tmpIter) {
693 count++;
694 }
695
696 if (count != (uint32Rang[UPPER_BOUND_INDEX] - uint32Rang[LOWER_BOUND_INDEX])) {
697 return false;
698 }
699
700 return true;
701 }
702 case AttrDataType::ATTR_DATA_UINT32_RANGE: {
703 return (uint32Rang[LOWER_BOUND_INDEX] >= value_.uint32Rang[LOWER_BOUND_INDEX]) &&
704 (uint32Rang[UPPER_BOUND_INDEX] <= value_.uint32Rang[UPPER_BOUND_INDEX]);
705 }
706 default: {
707 return false;
708 }
709 }
710 }
711 } // namespace MultimediaPlugin
712 } // namespace OHOS
713