Permalink
Browse files

v5.0.1.9 - added formatting options to set number of decimals and dec…

…imal separator, available only from the command line for now
  • Loading branch information...
Adrian Michel
Adrian Michel committed Sep 14, 2017
1 parent 52b8504 commit e556d604dd2d1bb188709fb5f4ba6445edd9301f
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -32,7 +32,7 @@ using yloader::operator<<;
// **************************
//
// ABCDEFGHIJKLMNOPQRSTUVWXYZ
// *********** ** ***** * ***
// ********************** ***
#define COMMAND_LINE_HELP_SHORT _T( "?" )
#define COMMAND_LINE_HELP_LONG _T( "help" )
@@ -188,6 +188,12 @@ using yloader::operator<<;
#define ALTERNATE_UPDATE_DIRECTORY _T( "altupdatedir" )
#define FIXED_DECIMALS_COUNT_SHORT _T( "L")
#define FIXED_DECIMALS_COUNT_LONG _T( "fixeddecimalscount")
#define DECIMAL_SEPARATOR_SHORT _T( "U")
#define DECIMAL_SEPARATOR_LONG _T( "decimalseparator")
typedef std::map<std::string, unsigned int> CmdLineInfoBase;
class CmdLineInfo : public CmdLineInfoBase {
@@ -332,6 +338,11 @@ TCHAR* CmdLineInfo::x
IGNORE_SYMBOLS_LIST) _T( "ignore symbols from the specified file")},
{ARGS(
MAP_CHARACTER) _T( "if argument contains two characters, change first character to second character in data file name. If argument contains only on character, remove it from the data file name. See full documentation for more details")},
{ARGS(FIXED_DECIMALS_COUNT) _T("forces price values to display ")
_T("with fixed number of decimals ")
_T("specified by the argument")},
{ARGS(
DECIMAL_SEPARATOR) _T( "sets the character used as decimal separator, by default \".\"")},
{ARGS(
DO_NOT_CHECK_FOR_UPDATE) _T( "do not check for YLoader update at startup, by default will check if there is an update (only in console version)")}};
@@ -560,6 +571,12 @@ bool CmdLine::process() {
cmdLineInfo.fullName(MAP_CHARACTER_SHORT).c_str(),
po::value<std::vector<string> >(),
cmdLineInfo.description(MAP_CHARACTER_SHORT).c_str())(
cmdLineInfo.fullName(DECIMAL_SEPARATOR_SHORT).c_str(),
po::value<string>(),
cmdLineInfo.description(DECIMAL_SEPARATOR_SHORT).c_str())(
cmdLineInfo.fullName(FIXED_DECIMALS_COUNT_SHORT).c_str(),
po::value<int>(),
cmdLineInfo.description(FIXED_DECIMALS_COUNT_SHORT).c_str())(
cmdLineInfo.fullName(DO_NOT_CHECK_FOR_UPDATE_SHORT).c_str(),
po::value<bool>(&_doNotCheckForUpdate)
->default_value(DEFAULT_DO_NOT_CHECK_FOR_UPDATE)
@@ -739,6 +756,12 @@ bool CmdLine::process() {
if (vm.count(yloader::ws2s(MAP_CHARACTER_LONG)) > 0)
_mapCharacters.set(vm[yloader::ws2s(MAP_CHARACTER_LONG)]
.as<std::vector<std::string> >());
if (vm.count(yloader::ws2s(FIXED_DECIMALS_COUNT_LONG)) > 0)
_fixedDecimalsCount.set(
vm[yloader::ws2s(FIXED_DECIMALS_COUNT_LONG)].as<int>());
if (vm.count(yloader::ws2s(DECIMAL_SEPARATOR_LONG)) > 0)
_decimalSeparator.set(yloader::s2ws(
vm[yloader::ws2s(DECIMAL_SEPARATOR_LONG)].as<string>()));
return true;
}
@@ -809,6 +832,8 @@ CmdLinePtr ysession() {
SET_NON_STR(autoExit, _setAutoExit)
SET_STR(ignoreSymbolsList, _setIgnoreSymbolsList)
SET_NON_STR(mapCharacters, _setMapCharacters)
SET_NON_STR(fixedDecimalsCount, _setFixedDecimalsCount)
SET_STR(decimalSeparator, _setDecimalSeparator)
_setUpdater(cmdLine->alternateUpdateHostName(),
cmdLine->alternateUpdateDirectory());
if (cmdLine->addSymbol().isSet()) {
View
@@ -79,6 +79,8 @@ class CmdLine {
StringSettable _alternateUpdateHost;
StringSettable _alternateUpdateDirectory;
StrVectorSettable _mapCharacters;
IntSettable _fixedDecimalsCount;
StringSettable _decimalSeparator;
public:
CmdLine();
@@ -285,6 +287,14 @@ class CmdLine {
bool doNotCheckForUpdate() const { return _doNotCheckForUpdate; }
const StrVectorSettable& mapCharacters() const { return _mapCharacters; }
const IntSettable fixedDecimalsCount() const { return _fixedDecimalsCount; }
const StringSettable& decimalSeparator() const { return _decimalSeparator; }
int fixedDecimalsCount(int def) const {
return _fixedDecimalsCount.isSet() ? _fixedDecimalsCount.getValue() : def;
}
const std::wstring decimalSeparator(const std::wstring& def) const {
return _decimalSeparator.isSet() ? _decimalSeparator.getValue() : def;
}
};
class CmdLineException : public std::exception {
@@ -351,6 +361,8 @@ void _setAutoExit(bool autoExit);
void _setIgnoreSymbolsList(const TCHAR* symbolsList);
void _setDoNotCheckForUpdate(bool doNotCheckForUpdate);
void _setMapCharacters(const std::vector<std::string>& mapCharacters);
void _setFixedDecimalsCount(unsigned int count);
void _setDecimalSeparator(const TCHAR* decimalSeparator);
void _showError(const TCHAR* text, const TCHAR* title);
void _showInfo(const TCHAR* text, const TCHAR* title);
@@ -231,6 +231,10 @@ int _tmain(int argc, _TCHAR* argv[]) {
bool appendToLog(cmdLine->appendToLog(DEFAULT_APPEND_TO_LOG));
bool logOnlyErrors(cmdLine->logOnlyErrors(DEFAULT_LOG_ONLY_ERRORS));
int fixedDecimalsCount(
cmdLine->fixedDecimalsCount(DEFAULT_FIXED_DECIMALS_COUNT));
const std::wstring decimalSeparator(
cmdLine->decimalSeparator(DEFAULT_DECIMAL_SEPARATOR));
DataParams dataParams(
cmdLine->errorSymbolsListFileName(DEFAULT_ERROR_SYMBOLS_LIST),
@@ -254,14 +258,16 @@ int _tmain(int argc, _TCHAR* argv[]) {
cmdLine->handlingInvalidData(DEFAULT_HANDLING_INVALID_DATA),
cmdLine->handlingVolume0(DEFAULT_VOLUME0_INVALID), connections,
DEFAULT_AUTO_SELECT_OUTPUT_PATH, // cmdLine->autoSelectOutputPath(
// DEFAULT_AUTO_SELECT_OUTPUT_PATH ),
// DEFAULT_AUTO_SELECT_OUTPUT_PATH
// ),
_T( "" ), cm, cmdLine->fieldSeparator(DEFAULT_FIELD_SEPARATOR),
cmdLine->volumeMultiplier(DEFAULT_VOLUME_MULTIPLIER),
cmdLine->dataFileHeader(),
cmdLine->dateSeparator(DEFAULT_DATE_SEPARATOR), cmdLine->outputFile(),
symbolsFileName, cmdLine->extension(DEFAULT_EXTENSION),
cmdLine->noReloadOldData(DEFAULT_DONT_RELOAD_DATA_IN_UPDATE_MODE),
logFile, appendToLog, logOnlyErrors,
logFile, appendToLog, logOnlyErrors, fixedDecimalsCount,
decimalSeparator,
cmdLine->enableRegexFomratting(DEFAULT_ENABLE_REGEX_FORMATTING),
cmdLine->regexMatch(DEFAULT_MATCH_REGEX),
cmdLine->regexFormat(DEFAULT_FORMAT_STRING),
@@ -491,3 +497,7 @@ void _showError(const TCHAR* text, const TCHAR* title) { printLine(text); }
void _showInfo(const TCHAR* text, const TCHAR* title) { printLine(text); }
bool _setUpdater(const StringSettable&, const StringSettable&) { return true; }
void _setFixedDecimalsCount(unsigned int count) {}
void _setDecimalSeparator(const TCHAR* decimalSeparator) {}
View
@@ -16,14 +16,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
// SHARED_HANDLERS can be defined in an ATL project implementing preview,
// thumbnail and search filter handlers and allows sharing of document code with
// that project.
#ifndef SHARED_HANDLERS
#include "yloader.h"
#endif
#include "yloaderDoc.h"
#include "YloaderView.h"
#include "yloaderDoc.h"
#include <defaults.h>
#include "EmptyDataPathPromptDlg.h"
@@ -165,6 +166,8 @@ void CYloaderView::SaveParams(bool force, bool updateData) {
WriteProfileInt(_T("IgnoreErrorSymbolsList"), _ignoreErrorSymbolsList);
WriteProfileString(_T("NotifyOnlyIfNewerVersion"),
_notifyOnlyIfNewerVersion);
WriteProfileString(_T("DecimalSeparator"), _decimalSeparator);
WriteProfileInt(_T("FixedDecimalsCount"), _fixedDecimalsCount);
}
}
@@ -273,15 +276,19 @@ void CYloaderView::LoadParams(const std::wstring& defSymbolsFileName,
_characterMapping.set(cmfrom, cmto);
_decimalSeparator =
GetProfileString(_T("DecimalSeparator"), DEFAULT_DECIMAL_SEPARATOR);
_fixedDecimalsCount =
GetProfileInt(_T("FixedDecimalsCount"), DEFAULT_FIXED_DECIMALS_COUNT);
/*
if (!enableExtraFeatures())
{
// these features are enabled in the registered version only
m_autoStartDownloading = false;
_threads = 1;
_logFile = _T("");
}
*/
if (!enableExtraFeatures())
{
// these features are enabled in the registered version only
m_autoStartDownloading = false;
_threads = 1;
_logFile = _T("");
}
*/
if (!yloader::fileExists(getYLoaderSettingsFile())) SaveParams(true, false);
}
@@ -402,7 +409,7 @@ void CYloaderView::OnInitialUpdate() {
// Create the colored <SoftechSoftware> sign
// m_sessionStatusCtrl.SubclassDlgItem(IDC_STATIC_SESSION_STATUS_VALUE,
//this);
// this);
LoadParams(_defSymbolsFileName, _defDataPath);
@@ -819,12 +826,12 @@ void CYloaderView::OnTimer(UINT_PTR nIDEvent) {
// if (b)
{
// m_sessionStatusCtrl.SetTextColor(true,
//0X7f00);
// 0X7f00);
// m_sessionStatusCtrl.SetBkColor(_bk);
} // else
{
// m_sessionStatusCtrl.SetTextColor(true,
//0xffffff);
// 0xffffff);
// m_sessionStatusCtrl.SetBkColor(0x7f00);
}
// m_sessionStatusCtrl.RedrawWindow();
@@ -835,12 +842,12 @@ void CYloaderView::OnTimer(UINT_PTR nIDEvent) {
// if (b)
{
// m_sessionStatusCtrl.SetTextColor(true,
//0Xff);
// 0Xff);
// m_sessionStatusCtrl.SetBkColor(_bk);
} // else
{
// m_sessionStatusCtrl.SetTextColor(true,
//0xffffff);
// 0xffffff);
// m_sessionStatusCtrl.SetBkColor(0xff);
}
}
@@ -853,13 +860,13 @@ void CYloaderView::OnTimer(UINT_PTR nIDEvent) {
m_sessionStatusCtrl.SetWindowText(_T( "Canceled"));
// m_sessionStatusCtrl.SetBkColor(0xff);
// m_sessionStatusCtrl.SetTextColor(true,
//0xffffff);
// 0xffffff);
} else {
OutputDebugString(_T("completed\n"));
m_sessionStatusCtrl.SetWindowText(_T("Completed"));
// m_sessionStatusCtrl.SetBkColor(0x7f00);
// m_sessionStatusCtrl.SetTextColor(true,
//0xffffff);
// 0xffffff);
}
// todo: write errors if session cancelled? Do write for now
View
@@ -248,6 +248,8 @@ class CYloaderView : public CFormView, public Refreshable {
bool _ignoreErrorSymbolsList;
std::wstring _ignoreSymbolsList;
std::wstring _notifyOnlyIfNewerVersion;
unsigned int _fixedDecimalsCount;
std::wstring _decimalSeparator;
WriteFileSymbolsListPtr _errorSymbolsListFile;
@@ -525,6 +527,13 @@ class CYloaderView : public CFormView, public Refreshable {
_characterMapping = map;
}
void setFixedDecimalsCount(unsigned int count) {
_fixedDecimalsCount = count;
}
void setDecimalSeparator(const std::wstring& decimalSeparator) {
_decimalSeparator = decimalSeparator;
}
void setAdjustment(bool a) { m_Adjustment = a ? TRUE : FALSE; }
void setValidatePrices(bool v) { m_validatePrices = v; }
@@ -552,8 +561,8 @@ class CYloaderView : public CFormView, public Refreshable {
_volumeMultiplier, _fileHeader, _dateSeparator,
std::wstring(getSaveFileAll()), std::wstring(getSymbolsFileName()),
_fileNameExtension, _dontReloadOldDataInUpdateMode, _logFile,
_appendToLog, _logOnlyErrors, _enableRegexFormatting, _matchRegex,
_formatString, _regexFlags));
_appendToLog, _logOnlyErrors, _fixedDecimalsCount, _decimalSeparator,
_enableRegexFormatting, _matchRegex, _formatString, _regexFlags));
}
void LoadParams(const std::wstring& defSymbolsFileName,
View
@@ -16,15 +16,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
#include "afxwinappex.h"
#include "MainFrm.h"
#include "afxdialogex.h"
#include "afxwinappex.h"
#include "yloader.h"
#include "MainFrm.h"
#include "yloaderDoc.h"
#include "YloaderView.h"
#include <CmdLine.h>
#include <versionno.h>
#include "YloaderView.h"
#include "yloaderDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -392,6 +393,14 @@ void _setMapCharacters(const std::vector<std::string>& mapCharacters) {
getView()->setCharacterMapping(mapCharacters);
}
void _setFixedDecimalsCount(unsigned int count) {
getView()->setFixedDecimalsCount(count);
}
void _setDecimalSeparator(const TCHAR* decimalSeparator) {
getView()->setDecimalSeparator(std::wstring(decimalSeparator));
}
bool __stdcall cl() {
try {
return ysession();
Oops, something went wrong.

0 comments on commit e556d60

Please sign in to comment.