progress...
diff --git a/inc/qcbor.h b/inc/qcbor.h
index 88d36e6..919fe78 100644
--- a/inc/qcbor.h
+++ b/inc/qcbor.h
@@ -793,7 +793,24 @@
should be treated as such. The strange situation is a CPU with a very
small size_t (e.g., a 16-bit CPU) and a large string (e.g., > 65KB).
*/
- QCBOR_ERR_STRING_TOO_LONG = 24
+ QCBOR_ERR_STRING_TOO_LONG = 24,
+
+ /** Number conversion failed because of sign. For example a negative
+ int64_t can't be converted to a uint64_t */
+ QCBOR_ERR_NUMBER_SIGN_CONVERSION = 25,
+
+ /** A conversion is possible, but the option for it was not set. For
+ example conversion from a float to an int64_t without the XXX option. TODO: */
+ QCBOR_ERR_CONVERSION_NOT_REQUESTED = 26,
+
+ /** When converting a decoded number, the value is too large or to small
+ for the conversion target */
+ QCBOR_ERR_CONVERSION_UNDER_OVER_FLOW = 27,
+
+ /** When decodeing for a specific type, the type was not was expected.
+ See also \ref QCBOR_ERR_CONVERSION_NOT_REQUESTED which in many cases
+ is effectively the same error */
+ QCBOR_ERR_NOT_EXPECTED_TYPE = 28,
} QCBORError;
@@ -2627,8 +2644,16 @@
void QCBORDecode_GetInt64(QCBORDecodeContext *pCtx, int64_t *pValue);
-void QCBORDecode_GetInt64X(QCBORDecodeContext *pCtx, uint32_t uOptions, QCBORLabel *pLabel, int64_t *pValue);
+void QCBORDecode_GetInt64Convert(QCBORDecodeContext *pCtx, uint32_t uOptions, int64_t *pValue);
+void QCBORDecode_GetInt64ConvertAll(QCBORDecodeContext *pCtx, uint32_t uOptions, int64_t *pValue);
+
+
+void QCBORDecode_GetUInt64(QCBORDecodeContext *pCtx, uint64_t *pValue);
+
+void QCBORDecode_GetUInt64Convert(QCBORDecodeContext *pCtx, uint32_t uOptions, QCBORLabel *pLabel, uint64_t *pValue);
+
+void QCBORDecode_GetUInt64ConvertAll(QCBORDecodeContext *pCtx, uint32_t uOptions, QCBORLabel *pLabel, uint64_t *pValue);
/**
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index ad2906c..fa55190 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -1750,18 +1750,21 @@
-void QCBORDecode_GetBool(QCBORDecodeContext *pMe, QCBORLabel *pLabel, bool *pValue)
+void QCBORDecode_GetBool(QCBORDecodeContext *pMe, bool *pValue)
{
- QCBORItem Item;
- QCBORError nError;
-
- nError = QCBORDecode_GetNext(pMe, &Item);
- if(nError) {
- pMe->nLastError = nError;
+ if(pMe->nLastError != QCBOR_SUCCESS) {
+ // Already in error state, do nothing
return;
}
- // TODO: label handling
+ QCBORError nError;
+ QCBORItem Item;
+
+ nError = QCBORDecode_GetNext(pMe, &Item);
+ if(nError != QCBOR_SUCCESS) {
+ pMe->nLastError = nError;
+ return;
+ }
switch(Item.uDataType) {
case QCBOR_TYPE_TRUE:
@@ -1773,7 +1776,8 @@
break;
default:
- pMe->nLastError = 88; // BAD TYPE
+ pMe->nLastError = QCBOR_ERR_NOT_EXPECTED_TYPE;
+ break;
}
}
@@ -1782,8 +1786,10 @@
* Plain, b64, b64url, URI, regex, MIME Text
* One function for each with options to expect plain?
* One function for all so you can say what you want?
+ *
+ * A label is expected if pLabel is not NULL.
*/
-void QCBORDecode_GetText(QCBORDecodeContext *pMe, QCBORLabel *pLabel, UsefulBufC *pValue)
+void QCBORDecode_GetTextFoo(QCBORDecodeContext *pMe, QCBORLabel *pLabel, UsefulBufC *pValue)
{
QCBORItem Item;
QCBORError nError;
@@ -1794,7 +1800,16 @@
return;
}
- // TODO: label handling
+ if(pLabel != NULL) {
+ if(Item.uLabelType == QCBOR_TYPE_NONE) {
+ pMe->nLastError = 9; // TODO: error code
+ return;
+ } else {
+ // TODO: what about label allocation?
+ pLabel->uLabelType = Item.uLabelType;
+ pLabel->label.xx = Item.label.int64; // TOOD: figure out assignment
+ }
+ }
switch(Item.uDataType) {
case QCBOR_TYPE_TEXT_STRING:
@@ -1802,11 +1817,63 @@
break;
default:
- pMe->nLastError = 88; // BAD TYPE
+ pMe->nLastError = QCBOR_ERR_NOT_EXPECTED_TYPE;
}
}
+/*
+ Options for MIME data, CBOR, positive big num, negative big num ??
+ */
+void QCBORDecode_GetStringInternal(QCBORDecodeContext *pMe, UsefulBufC *pValue, uint8_t uType)
+{
+ if(pMe->nLastError != QCBOR_SUCCESS) {
+ // Already in error state, do nothing
+ return;
+ }
+
+ QCBORError nError;
+ QCBORItem Item;
+
+ nError = QCBORDecode_GetNext(pMe, &Item);
+ if(nError != QCBOR_SUCCESS) {
+ pMe->nLastError = nError;
+ return;
+ }
+
+ if(Item.uDataType == uType) {
+ *pValue = Item.val.string;
+ } else {
+ pMe->nLastError = QCBOR_ERR_NOT_EXPECTED_TYPE;
+ }
+}
+
+void QCBORDecode_GetBytes(QCBORDecodeContext *pMe, QCBORLabel *pLabel, UsefulBufC *pValue)
+{
+ QCBORDecode_GetStringInternal(pMe, pValue, QCBOR_TYPE_BYTE_STRING);
+}
+
+
+void QCBORDecode_GetText(QCBORDecodeContext *pMe, QCBORLabel *pLabel, UsefulBufC *pValue)
+{
+ QCBORDecode_GetStringInternal(pMe, pValue, QCBOR_TYPE_TEXT_STRING);
+}
+
+
+void QCBORDecode_GetPosBignum(QCBORDecodeContext *pMe, QCBORLabel *pLabel, UsefulBufC *pValue)
+{
+ // TODO: do these have to be tagged?
+ // Probably should allow tagged or untagged, but not wrong-tagged
+ QCBORDecode_GetStringInternal(pMe, pValue, QCBOR_TYPE_POSBIGNUM);
+}
+
+void QCBORDecode_GetNegBignum(QCBORDecodeContext *pMe, QCBORLabel *pLabel, UsefulBufC *pValue)
+{
+ QCBORDecode_GetStringInternal(pMe, pValue, QCBOR_TYPE_NEGBIGNUM);
+}
+
+
+
/* Convert a decimal fraction to an int64_t without using
floating point or math libraries. Most decimal fractions
@@ -1821,7 +1888,7 @@
/* This loop will run a maximum of 19 times because
* INT64_MAX < 10 ^^ 19. More than that will cause
- * exist with the overflow error
+ * exit with the overflow error
*/
while(nExponent > 0) {
if(nResult > INT64_MAX / 10) {
@@ -1843,6 +1910,103 @@
}
+
+
+uint8_t Exponentitate10U(uint64_t uMantissa, int64_t nExponent, uint64_t *puResult)
+{
+ uint64_t uResult;
+
+ uResult = uMantissa;
+
+ /* This loop will run a maximum of 19 times because
+ * UINT64_MAX < 10 ^^ 19. More than that will cause
+ * exit with the overflow error
+ */
+ while(nExponent > 0) {
+ if(uResult > UINT64_MAX / 10) {
+ return 99; // Error overflow
+ }
+ uResult = uResult * 10;
+ nExponent--;
+ }
+
+ while(nExponent < 0 ) {
+ if(uResult == 0) {
+ return 98; // Underflow error
+ }
+ uResult = uResult / 10;
+ nExponent--;
+ }
+
+ *puResult = uResult;
+
+ return 0;
+}
+
+uint8_t Exponentitate10S(int64_t nMantissa, int64_t nExponent, int64_t *pnResult)
+{
+ // TODO: is this less code than duplicating the above function?
+ uint64_t uResult;
+
+ uint64_t uMantissa = nMantissa > 0 ? (uint64_t)nMantissa : (uint64_t)-nMantissa;
+
+ Exponentitate10U(uMantissa, nExponent, &uResult);
+
+ if(uResult > INT64_MAX) {
+ return 99; // Result is too large
+ } else if(uResult < (uint64_t)-INT64_MIN) {
+ return 98; // results is too small (large negative number)
+ }
+
+ // TODO: these casts might not work.
+ *pnResult = nMantissa > 0 ? (int64_t)uResult : (int64_t) -uResult;
+
+ return 0;
+}
+
+
+uint8_t Exponentitate10SS(int64_t nMantissa, int64_t nExponent, uint64_t *puResult)
+{
+ if(nMantissa < 0) {
+ return 77; // can't return a negative result in an unsigned.
+ }
+
+ return Exponentitate10U((uint64_t)nMantissa, nExponent, puResult);
+}
+
+
+uint8_t Exponentitate10US(uint64_t uMantissa, int64_t nExponent, int64_t *pnResult)
+{
+ // TODO: is this less code than duplicating the above function?
+ uint64_t uResult;
+
+ uint8_t uR;
+
+ uR = Exponentitate10U(uMantissa, nExponent, &uResult);
+ if(uR) {
+ return uR;
+ }
+
+ if(uResult > INT64_MAX) {
+ return 88;
+ }
+ *pnResult = (int64_t)uResult;
+
+ return 0;
+}
+
+#include <math.h>
+
+uint8_t Exponentitate10F(uint64_t uMantissa, int64_t nExponent, double *pfResult)
+{
+ // TODO: checkout exceptions; what is HUGE_VAL?
+ *pfResult = pow((double)10, (double)nExponent) * (double)uMantissa;
+
+ //if(*pfResult == HUGE_VAL)
+ return 0;
+}
+
+
/* Convert a decimal fraction to an int64_t without using
floating point or math libraries. Most decimal fractions
will not fit in an int64_t and this will error out with
@@ -1887,7 +2051,7 @@
B1) output is signed INT64_MAX
B2) output is unsigned error
*/
-uint8_t ConvertBigNum(const UsefulBufC BigNum, uint64_t uMax, uint64_t *pResult)
+QCBORError ConvertBigNum(const UsefulBufC BigNum, uint64_t uMax, uint64_t *pResult)
{
uint64_t nResult;
@@ -1896,7 +2060,7 @@
size_t uLen = BigNum.len;
while(uLen--) {
if(nResult > uMax << 8) {
- return 99; // over flow
+ return QCBOR_ERR_CONVERSION_UNDER_OVER_FLOW;
}
nResult = (nResult >> 8) + *pByte;
}
@@ -1905,12 +2069,33 @@
return 0;
}
-int ConvertPositiveBigNumToUnSigned(const UsefulBufC BigNum, uint64_t *pResult)
+
+
+QCBORError ConvertBigNumToDouble(const UsefulBufC BigNum, uint64_t uMax, double *pResult)
+{
+ double nResult;
+
+ nResult = 0;
+ const uint8_t *pByte = BigNum.ptr;
+ size_t uLen = BigNum.len;
+ /* This will overflow and become the float value INFINITY if the number
+ is too large to fit. No error will be logged.
+ TODO: should an error be logged? */
+ while(uLen--) {
+ nResult = (nResult * 256) + *pByte;
+ }
+
+ *pResult = nResult;
+ return 0;
+}
+
+
+QCBORError ConvertPositiveBigNumToUnSigned(const UsefulBufC BigNum, uint64_t *pResult)
{
return ConvertBigNum(BigNum, UINT64_MAX, pResult);
}
-uint8_t ConvertPositiveBigNumToSigned(const UsefulBufC BigNum, int64_t *pResult)
+QCBORError ConvertPositiveBigNumToSigned(const UsefulBufC BigNum, int64_t *pResult)
{
uint64_t uResult;
uint8_t n = ConvertBigNum(BigNum, INT64_MAX, &uResult);
@@ -1923,7 +2108,7 @@
}
-uint8_t ConvertNegativeBigNumToSigned(const UsefulBufC BigNum, int64_t *pResult)
+QCBORError ConvertNegativeBigNumToSigned(const UsefulBufC BigNum, int64_t *pResult)
{
uint64_t uResult;
uint8_t n = ConvertBigNum(BigNum, INT64_MAX-1, &uResult);
@@ -1935,6 +2120,10 @@
return 0;
}
+// No function to convert a negative bignum to unsigned; it is an error
+
+
+
int ConvertXYZ(const UsefulBufC Mantissa, int64_t nExponent, int64_t *pResult)
{
int64_t nMantissa;
@@ -1956,8 +2145,18 @@
#define QCBOR_DECODE_TYPE_DECIMAL_FRACTION 0x05
#define QCBOR_DECODE_TYPE_BIG_NUM 0x06
-void QCBORDecode_GetInt64X(QCBORDecodeContext *pMe, uint32_t uOptions, QCBORLabel *pLabel, int64_t *pValue)
+
+/*
+ Get the next item as an int64_t. The CBOR type can be unsigned, negative, float
+ a big float, a decimal fraction or a big num. Conversion will be dones as
+ expected. Some cases will error out with under or over flow.
+ */
+void QCBORDecode_GetInt64ConvertInternal(QCBORDecodeContext *pMe, uint32_t uOptions, int64_t *pValue, QCBORItem *pItem)
{
+ if(pMe->nLastError != QCBOR_SUCCESS) {
+ return;
+ }
+
QCBORItem Item;
QCBORError nError;
@@ -1967,23 +2166,13 @@
return;
}
- if(pLabel != NULL) {
- if(Item.uLabelType == QCBOR_TYPE_NONE) {
- pMe->nLastError = 9; // TODO: error code
- return;
- } else {
- // TODO: what about label allocation?
- pLabel->uLabelType = Item.uLabelType;
- pLabel->label.xx = Item.label.int64; // TOOD: figure out assignment
- }
- }
-
switch(Item.uDataType) {
case QCBOR_TYPE_FLOAT:
if(uOptions & QCBOR_DECODE_TYPE_FLOAT) {
+ // TODO: what about under/overflow here?
*pValue = (int64_t)Item.val.dfnum;
} else {
- pMe->nLastError = 99; // TODO: error code
+ pMe->nLastError = QCBOR_ERR_CONVERSION_NOT_REQUESTED;
}
break;
@@ -1991,7 +2180,7 @@
if(uOptions & QCBOR_DECODE_TYPE_INT64) {
*pValue = Item.val.int64;
} else {
- pMe->nLastError = 99; // TODO: error code
+ pMe->nLastError = QCBOR_ERR_CONVERSION_NOT_REQUESTED;
}
break;
@@ -2000,13 +2189,43 @@
if(Item.val.uint64 < INT64_MAX) {
*pValue = Item.val.int64;
} else {
- pMe->nLastError = 88; // integer overflow
+ pMe->nLastError = QCBOR_ERR_CONVERSION_UNDER_OVER_FLOW;
}
} else {
- pMe->nLastError = 99; // TODO: error code
+ pMe->nLastError = QCBOR_ERR_CONVERSION_NOT_REQUESTED;
}
break;
+ default:
+ pMe->nLastError = 99; // TODO: fix error code after merge
+ }
+}
+
+/* This works for signed, unsigned and float */
+void QCBORDecode_GetInt64Convert(QCBORDecodeContext *pMe, uint32_t uOptions, int64_t *pValue)
+{
+ QCBORItem Item;
+ QCBORDecode_GetInt64ConvertInternal(pMe, uOptions, pValue, &Item);
+}
+
+
+
+/*
+ Get the next item as an int64_t. The CBOR type can be unsigned, negative, float
+ a big float, a decimal fraction or a big num. Conversion will be dones as
+ expected. Some cases will error out with under or over flow.
+ */
+void QCBORDecode_GetInt64ConvertAll(QCBORDecodeContext *pMe, uint32_t uOptions, int64_t *pValue)
+{
+ QCBORItem Item;
+
+ QCBORDecode_GetInt64ConvertInternal(pMe, uOptions, pValue, &Item);
+
+ if(pMe->nLastError != QCBOR_SUCCESS) {
+ return;
+ }
+
+ switch(Item.uDataType) {
case QCBOR_TYPE_DECIMAL_FRACTION:
if(uOptions & QCBOR_DECODE_TYPE_DECIMAL_FRACTION) {
pMe->nLastError = Exponentitate10(Item.val.expAndMantissa.Mantissa.nInt,
@@ -2101,6 +2320,55 @@
}
}
+
+
+void QCBORDecode_GetUInt64ConvertInternal(QCBORDecodeContext *pMe, uint32_t uOptions, uint64_t *pValue, QCBORItem *pItem)
+{
+ QCBORItem Item;
+ QCBORError nError;
+
+ nError = QCBORDecode_GetNext(pMe, &Item);
+ if(nError) {
+ pMe->nLastError = nError;
+ return;
+ }
+
+ switch(Item.uDataType) {
+ case QCBOR_TYPE_FLOAT:
+ if(uOptions & QCBOR_DECODE_TYPE_FLOAT) {
+ if(Item.val.dfnum >= 0) {
+ *pValue = (uint64_t)Item.val.dfnum;
+ } else {
+ pMe->nLastError = QCBOR_ERR_NUMBER_SIGN_CONVERSION;
+ }
+ } else {
+ pMe->nLastError = QCBOR_ERR_CONVERSION_NOT_REQUESTED;
+ }
+ break;
+
+ case QCBOR_TYPE_INT64:
+ if(uOptions & QCBOR_DECODE_TYPE_INT64) {
+ if(Item.val.int64 >= 0) {
+ *pValue = (uint64_t)Item.val.int64;
+ } else {
+ pMe->nLastError = QCBOR_ERR_NUMBER_SIGN_CONVERSION;
+ }
+ } else {
+ pMe->nLastError = QCBOR_ERR_CONVERSION_NOT_REQUESTED;
+ }
+ break;
+
+ case QCBOR_TYPE_UINT64:
+ if(uOptions & QCBOR_DECODE_TYPE_UINT64) {
+ *pValue = Item.val.uint64;
+ } else {
+ pMe->nLastError = QCBOR_ERR_CONVERSION_NOT_REQUESTED;
+ }
+ break;
+ }
+}
+
+
void QCBORDecode_GetUInt64X(QCBORDecodeContext *pMe, uint32_t uOptions, QCBORLabel *pLabel, uint64_t *pValue)
{
QCBORItem Item;
@@ -2246,10 +2514,159 @@
}
}
-void QCBORDecode_GetDouble(QCBORDecodeContext *pMe, uint32_t uOptions, QCBORLabel *pLabel, uint64_t *pValue)
+
+/*
+
+ Convert from bignums,
+
+ */
+void QCBORDecode_GetDouble(QCBORDecodeContext *pMe, uint32_t uOptions, QCBORLabel *pLabel, double *pValue)
{
/* the same range of conversions */
+ /* Conversion from bignums, decimal fractions and such will be interesting */
+
+ QCBORItem Item;
+ QCBORError nError;
+
+ nError = QCBORDecode_GetNext(pMe, &Item);
+ if(nError) {
+ pMe->nLastError = nError;
+ return;
+ }
+
+ if(pLabel != NULL) {
+ if(Item.uLabelType == QCBOR_TYPE_NONE) {
+ pMe->nLastError = 9; // TODO: error code
+ return;
+ } else {
+ // TODO: what about label allocation?
+ pLabel->uLabelType = Item.uLabelType;
+ pLabel->label.xx = Item.label.int64; // TOOD: figure out assignment
+ }
+ }
+
+ switch(Item.uDataType) {
+ case QCBOR_TYPE_FLOAT:
+ if(uOptions & QCBOR_DECODE_TYPE_FLOAT) {
+ *pValue = Item.val.dfnum;
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_INT64:
+ if(uOptions & QCBOR_DECODE_TYPE_INT64) {
+ // TODO: how does this work?
+ *pValue = (double)Item.val.int64;
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_UINT64:
+ if(uOptions & QCBOR_DECODE_TYPE_UINT64) {
+ *pValue = (double)Item.val.uint64;
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_DECIMAL_FRACTION:
+ if(uOptions & QCBOR_DECODE_TYPE_DECIMAL_FRACTION) {
+ pMe->nLastError = Exponentitate10(Item.val.expAndMantissa.Mantissa.nInt,
+ Item.val.expAndMantissa.nExponent,
+ pValue);
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_BIGFLOAT:
+ if(uOptions & QCBOR_DECODE_TYPE_BIGFLOAT) {
+ pMe->nLastError = Exponentitate2(Item.val.expAndMantissa.Mantissa.nInt,
+ Item.val.expAndMantissa.nExponent,
+ pValue);
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_POSBIGNUM:
+ if(uOptions & QCBOR_DECODE_TYPE_BIG_NUM) {
+ pMe->nLastError = ConvertPositiveBigNumToSigned(Item.val.bigNum, pValue);
+ } else {
+ pMe->nLastError = 99;
+ }
+ break;
+
+ case QCBOR_TYPE_NEGBIGNUM:
+ if(uOptions & QCBOR_DECODE_TYPE_BIG_NUM) {
+ pMe->nLastError = ConvertNegativeBigNumToSigned(Item.val.bigNum, pValue);
+ } else {
+ pMe->nLastError = 99;
+ }
+ break;
+
+ case QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM:
+ if(uOptions & QCBOR_DECODE_TYPE_DECIMAL_FRACTION) {
+ int64_t nMantissa;
+ pMe->nLastError = ConvertPositiveBigNumToSigned(Item.val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ if(!pMe->nLastError) {
+ pMe->nLastError = Exponentitate10(nMantissa,
+ Item.val.expAndMantissa.nExponent,
+ pValue);
+ }
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_DECIMAL_FRACTION_NEG_BIGNUM:
+ if(uOptions & QCBOR_DECODE_TYPE_DECIMAL_FRACTION) {
+ int64_t nMantissa;
+ pMe->nLastError = ConvertNegativeBigNumToSigned(Item.val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ if(!pMe->nLastError) {
+ pMe->nLastError = Exponentitate10(nMantissa,
+ Item.val.expAndMantissa.nExponent,
+ pValue);
+ }
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_BIGFLOAT_POS_BIGNUM:
+ if(uOptions & QCBOR_DECODE_TYPE_DECIMAL_FRACTION) {
+ int64_t nMantissa;
+ pMe->nLastError = ConvertPositiveBigNumToSigned(Item.val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ if(!pMe->nLastError) {
+ pMe->nLastError = Exponentitate2(nMantissa,
+ Item.val.expAndMantissa.nExponent,
+ pValue);
+ }
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+
+ case QCBOR_TYPE_BIGFLOAT_NEG_BIGNUM:
+ if(uOptions & QCBOR_DECODE_TYPE_DECIMAL_FRACTION) {
+ int64_t nMantissa;
+ pMe->nLastError = ConvertNegativeBigNumToSigned(Item.val.expAndMantissa.Mantissa.bigNum, &nMantissa);
+ if(!pMe->nLastError) {
+ pMe->nLastError = Exponentitate2(nMantissa,
+ Item.val.expAndMantissa.nExponent,
+ pValue);
+ }
+ } else {
+ pMe->nLastError = 99; // TODO: error code
+ }
+ break;
+ }
+
+
+
}