You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/iBase/iUtils/ZxBaHelper.h

123 lines
4.8 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "Defines.h"
#include "LlUtils_global.h"
// QByteArray转换专用类
// 其实该类的很多函数可以以模版template函数
// 来实现但是通常template函数需要放.h文件中
// 故未采用。
class I_UTILSSHARED_EXPORT ZxBaHelper
{
public:
ZxBaHelper();
public:
/// @brief Vec与QByteArray相互转换
static bool convertVec2Ba(VecVariant& vec, QByteArray& ba);
static bool convertBa2Vec(VecVariant& vec, QByteArray& ba);
static bool convertVec2Ba(VecDouble& vec, QByteArray& ba);
static bool convertBa2Vec(VecDouble& vec, QByteArray& ba);
// static bool convertVec2Ba(VecDouble& vec, QByteArray& ba);
// static bool convertBa2Vec(VecDouble& vec, QByteArray& ba);
/// @brief VVec与QByteArray的转换
static bool convertVVec2Ba(VVecVariant& vvec, \
QByteArray& ba);
/// @brief QByteArray与VVec的转换
static bool convertBa2VVec(VVecVariant& vvec, \
QByteArray& ba);
/// @brief VVec与QByteArray的转换
static bool convertVVec2Ba(VVecDouble& vvec, \
QByteArray& ba);
/// @brief QByteArray与VVec的转换
static bool convertBa2VVec(VVecDouble& vvec, \
QByteArray& ba);
// /// @brief VecX、VecY与QByteArray的转换
// static bool convertVecXY2Ba(VecDouble& vecX, \
// VecDouble& vecY, \
// QByteArray& ba);
// /// @brief QByteArray与VecX、VecY的转换
// static bool convertBa2VecXY(VecDouble& vecX, \
// VecDouble& vecY, \
// QByteArray& ba);
/// @brief VecX、VecY与QByteArray的转换
static bool convertVecXY2Ba(VecDouble& vecX, \
VecDouble& vecY, \
QByteArray& ba);
/// @brief QByteArray与VecX、VecY的转换
static bool convertBa2VecXY(VecDouble& vecX, \
VecDouble& vecY, \
QByteArray& ba);
// /// @brief vvecXY 类似 vecXY << vecX << vecY
// static bool convertBa2VVecXY(VVecDouble& vvecXY, \
// QByteArray& ba);
/// @brief vvecXY 类似 vecXY << vecX << vecY
static bool convertBa2VVecXY(VVecDouble& vvecXY, \
QByteArray& ba);
/// @brief 把多个ba一起转换为VVec主要用于多相情况
/// @param vecBAs,流量数据体的ba三个油气水每个都内含x/y
/// @param vvec结果
/// @param bVertical如果为true则 vvec[0]为时间vvec[1]油vvec[2]为气vvec[3]为水
/// 如果为false则vvec[0]为 时间/油/气/水,其它均类似
static bool convertVecBa2VVecF(QVector<QByteArray>& vecBAs, \
VVecDouble& vvec, bool bVertical = true);
/// @brief 把多个ba一起转换为VVec主要用于多相情况
/// @param vecBAs,流量数据体的ba三个油气水每个都内含x/y
/// @param vvec结果
/// @param bVertical如果为true则 vvec[0]为时间vvec[1]油vvec[2]为气vvec[3]为水
/// 如果为false则vvec[0]为 时间/油/气/水,其它均类似
static bool convertVecBa2VVecV(QVector<QByteArray>& vecBAs, \
VVecVariant& vvec, bool bVertical = false);
/// @brief QVector<QPointF>
// 已经废弃
static bool convertBa2VecPoints(QVector<QPointF>& vec, \
QByteArray& ba);
/// @brief vvecData的每一个元素 (x,y)
static bool convertBa2VVecData(VVecVariant& vvecData, \
QByteArray& ba);
/// TODO 20231231 Old
// 已经废弃
static bool convertVVecData2BaEx(VVecVariant& vvecData, QByteArray& ba);
// 已经废弃
static bool convertBa2VVecDataEx(VVecVariant& vvecData, QByteArray& ba);
/// TODO 20231231 Old
// 已经废弃
static bool convertBa2VecData(VecDouble& vecData, QByteArray& ba);
// 已经废弃
static bool convertVecData2Ba(VecDouble& vecData, QByteArray& ba);
// ByteArray Image
static bool imgToBa(QImage& img, QByteArray& ba);
static bool baToImg(QImage& img, QByteArray& ba);
// ByteArray map
static bool mapToBa(QByteArray& ba, QMap<QString, QVariant>& map);
static bool baToMap(QByteArray& ba, QMap<QString, QVariant>& map);
static bool mapToBa(QByteArray& ba, QMap<QString, double>& map);
static bool baToMap(QByteArray& ba, QMap<QString, double>& map);
static bool mapToBa(QByteArray& ba, QMap<QString, VecDouble>& map);
static bool baToMap(QByteArray& ba, QMap<QString, VecDouble>& map);
};