-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathParseMktSymbolDiskFile.cpp
71 lines (51 loc) · 2.21 KB
/
ParseMktSymbolDiskFile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/************************************************************************
* Copyright(c) 2012, One Unified. All rights reserved. *
* email: [email protected] *
* *
* This file is provided as is WITHOUT ANY WARRANTY *
* without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* This software may not be used nor distributed without proper license *
* agreement. *
* *
* See the file LICENSE.txt for redistribution information. *
************************************************************************/
#include <fstream>
#include <iostream>
#include <stdexcept>
#include "ParseMktSymbolDiskFile.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace iqfeed { // IQFeed
// try http://stackoverflow.com/questions/2291802/is-there-a-c-iterator-that-can-iterate-over-a-file-line-by-line
void ParseMktSymbolDiskFile::Run( const std::string& sName ) {
std::ifstream file;
//char* name = "mktsymbols_v2.txt";
std::cout << "Opening Input Symbol File ";
std::cout << sName;
std::cout << " ... ";
file.open( sName.c_str() );
if ( file.bad() ) {
throw std::runtime_error( "Can't open input file" );
}
std::cout << std::endl;
std::cout << "Loading Symbols ..." << std::endl;
char line[ 500 ];
size_t cntLines( 0 );
file.getline( line, 500 ); // remove header line
file.getline( line, 500 );
while ( !file.fail() ) {
cntLines++;
iterator_t pLine1( line );
iterator_t pLine2( line + 500 );
if ( 0 != m_OnProcessLine ) m_OnProcessLine( pLine1, pLine2 );
file.getline( line, 500 );
// if ( 1000 < cntLines ) break;
}
std::cout << cntLines << " lines written" << std::endl;
file.close();
}
} // namespace iqfeed
} // namespace tf
} // namespace ou