1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // PBConfigData.cpp
- // merge6
- //
- // Created by Black Homles on 2024/9/24.
- //
- #include "PBConfigData.hpp"
- #include "rapidcsv.h"
- PBConfigData* PBConfigData::_gPBConfigData = nullptr;
- PBConfigData::PBConfigData() {
- }
- PBConfigData::~PBConfigData() {
- }
- PBConfigData* PBConfigData::getInstance() {
- if (_gPBConfigData == nullptr || !_gPBConfigData) {
- _gPBConfigData = new (std::nothrow) PBConfigData();
- }
- return _gPBConfigData;
- }
- void PBConfigData::initData(std::string cfgFN) {
- string fileName = cfgFN;
- _bannerInfoList.clear();
- if (!FileUtils::getInstance()->isFileExist(fileName)) {
- return;
- }
- std::string fullfiledata = FileUtils::getInstance()->getStringFromFile(fileName);
- std::stringstream sstream(fullfiledata);
- rapidcsv::Document tempDoc(sstream);
- int rowcount = (int)tempDoc.GetRowCount();
- for (int irow = 0; irow < rowcount; irow++) {
- bannerInfo tmpinfo;
- tmpinfo.bannerName = tempDoc.GetCell<string>("名称",irow);
- tmpinfo.bannerDes = tempDoc.GetCell<string>("描述",irow);
- tmpinfo.bannerType = tempDoc.GetCell<string>("类型",irow);
- tmpinfo.bannerFile = tempDoc.GetCell<string>("文件名称",irow);
- tmpinfo.bannerTitle = tempDoc.GetCell<string>("标题",irow);
- tmpinfo.bannerPlist = tempDoc.GetCell<string>("图集名称",irow);
- tmpinfo.bannerBGSp = tempDoc.GetCell<string>("背景图片",irow);
- tmpinfo.bannerPID = tempDoc.GetCell<string>("商品ID",irow);
- tmpinfo.bannerCutCount = tempDoc.GetCell<string>("折扣数字",irow);
- tmpinfo.bannerPrice = tempDoc.GetCell<string>("价格数字",irow);
- tmpinfo.bannerBtnStr = tempDoc.GetCell<string>("按钮文字",irow);
- tmpinfo.bannerTime = tempDoc.GetCell<int>("有效时间秒",irow);
- tmpinfo.item1ID = tempDoc.GetCell<string>("物品1ID",irow);
- tmpinfo.item1Type = tempDoc.GetCell<string>("物品1类型",irow);
- tmpinfo.item1Count = tempDoc.GetCell<int>("物品1数量",irow);
- tmpinfo.item1PNG = tempDoc.GetCell<string>("物品1图片",irow);
- tmpinfo.item2ID = tempDoc.GetCell<string>("物品2ID",irow);
- tmpinfo.item2Type = tempDoc.GetCell<string>("物品2类型",irow);
- tmpinfo.item2Count = tempDoc.GetCell<int>("物品2数量",irow);
- tmpinfo.item2PNG = tempDoc.GetCell<string>("物品2图片",irow);
- tmpinfo.item3ID = tempDoc.GetCell<string>("物品3ID",irow);
- tmpinfo.item3Type = tempDoc.GetCell<string>("物品3类型",irow);
- tmpinfo.item3Count = tempDoc.GetCell<int>("物品3数量",irow);
- tmpinfo.item3PNG = tempDoc.GetCell<string>("物品3图片",irow);
- tmpinfo.item3Des = tempDoc.GetCell<string>("物品3描述",irow);
- _bannerInfoList.push_back(tmpinfo);
- }
- //view config
- string fileName2 = "bannerViewConfig.csv";
- _bResList.clear();
- if (!FileUtils::getInstance()->isFileExist(fileName2)) {
- return;
- }
- std::string fullfiledata2 = FileUtils::getInstance()->getStringFromFile(fileName2);
- std::stringstream sstream2(fullfiledata2);
- rapidcsv::Document tempDoc2(sstream2);
- int rowcount2 = (int)tempDoc2.GetRowCount();
- for (int lopp = 1; lopp < rowcount2; lopp++) {
- string tmpstr = tempDoc2.GetCell<string>("资源名称",lopp);
- _bResList.push_back(tmpstr);
- }
- _thisDotcfg.sepWidth = tempDoc2.GetCell<int>("圆点宽度",0);
- _thisDotcfg.yStart = tempDoc2.GetCell<int>("圆点高度",0);
- _thisDotcfg.highSp = tempDoc2.GetCell<string>("圆点亮图",0);
- _thisDotcfg.normalSp = tempDoc2.GetCell<string>("圆点暗图",0);
- }
- PBConfigData::bannerInfo PBConfigData::getBannerInfo(string bName) {
- bannerInfo tmpinfo;
- for (int lopp = 0; lopp < _bannerInfoList.size(); lopp++) {
- if (_bannerInfoList[lopp].bannerName == bName) {
- tmpinfo = _bannerInfoList[lopp];
- break;
- }
- }
- return tmpinfo;
- }
- PBConfigData::sPBDotCfg PBConfigData::getViewDot() {
- return _thisDotcfg;
- }
|