File indexing completed on 2025-01-05 04:37:09

0001 /*
0002     SPDX-FileCopyrightText: 2005 Joris Guisson <joris.guisson@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #include "value.h"
0007 #include <qtextcodec.h>
0008 
0009 namespace bt
0010 {
0011 Value::Value()
0012     : type(INT)
0013     , ival(0)
0014     , big_ival(0)
0015 {
0016 }
0017 
0018 Value::Value(int val)
0019     : type(INT)
0020     , ival(val)
0021     , big_ival(val)
0022 {
0023 }
0024 
0025 Value::Value(Int64 val)
0026     : type(INT64)
0027     , big_ival(val)
0028 {
0029 }
0030 
0031 Value::Value(const QByteArray &val)
0032     : type(STRING)
0033     , ival(0)
0034     , strval(val)
0035     , big_ival(0)
0036 {
0037 }
0038 
0039 Value::Value(const Value &val)
0040     : type(val.type)
0041     , ival(val.ival)
0042     , strval(val.strval)
0043     , big_ival(val.big_ival)
0044 {
0045 }
0046 
0047 Value::~Value()
0048 {
0049 }
0050 
0051 QString Value::toString(QTextCodec *tc) const
0052 {
0053     if (!tc)
0054         return toString();
0055     else
0056         return tc->toUnicode(strval);
0057 }
0058 
0059 Value &Value::operator=(const Value &val)
0060 {
0061     type = val.type;
0062     ival = val.ival;
0063     strval = val.strval;
0064     big_ival = val.big_ival;
0065     return *this;
0066 }
0067 
0068 Value &Value::operator=(Int32 val)
0069 {
0070     type = INT;
0071     ival = val;
0072     big_ival = val;
0073     return *this;
0074 }
0075 
0076 Value &Value::operator=(Int64 val)
0077 {
0078     type = INT64;
0079     big_ival = val;
0080     return *this;
0081 }
0082 
0083 Value &Value::operator=(const QByteArray &val)
0084 {
0085     type = STRING;
0086     strval = val;
0087     big_ival = 0;
0088     return *this;
0089 }
0090 
0091 }