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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>LibOFX: ofx_container_security.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>ofx_container_security.cpp</h1><a href="fx-0_88_82_2lib_2ofx__container__security_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> ofx_container_security.cpp </span>
<a name="l00003"></a>00003 <span class="comment"> -------------------</span>
<a name="l00004"></a>00004 <span class="comment"> copyright : (C) 2002 by Benoit Grgoire</span>
<a name="l00005"></a>00005 <span class="comment"> email : bock@step.polymtl.ca</span>
<a name="l00006"></a>00006 <span class="comment">***************************************************************************/</span>
<a name="l00011"></a>00011 <span class="comment">/***************************************************************************</span>
<a name="l00012"></a>00012 <span class="comment"> * *</span>
<a name="l00013"></a>00013 <span class="comment"> * This program is free software; you can redistribute it and/or modify *</span>
<a name="l00014"></a>00014 <span class="comment"> * it under the terms of the GNU General Public License as published by *</span>
<a name="l00015"></a>00015 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or *</span>
<a name="l00016"></a>00016 <span class="comment"> * (at your option) any later version. *</span>
<a name="l00017"></a>00017 <span class="comment"> * *</span>
<a name="l00018"></a>00018 <span class="comment"> ***************************************************************************/</span>
<a name="l00019"></a>00019
<a name="l00020"></a>00020 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
<a name="l00022"></a>00022 <span class="preprocessor">#endif</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="preprocessor">#include <string></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="fx-0_88_82_2lib_2messages_8hh.html" title="Message IO functionality.">messages.hh</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="libofx-0_89_80_2inc_2libofx_8h.html" title="Main header file containing the LibOfx API.">libofx.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="fx-0_88_82_2lib_2ofx__containers_8hh.html" title="LibOFX internal object code.">ofx_containers.hh</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="fx-0_88_82_2lib_2ofx__utilities_8hh.html" title="Various simple functions for type conversion &amp; al.">ofx_utilities.hh</a>"</span>
<a name="l00029"></a>00029
<a name="l00030"></a>00030 <span class="keyword">extern</span> <a class="code" href="classOfxMainContainer.html" title="The root container. Created by the &lt;OFX&gt; OFX element or by the export functions...">OfxMainContainer</a> * <a class="code" href="ofc__sgml_8cpp.html#759a7d80c051f4f1adc2abae56002100">MainContainer</a>;
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="comment">/***************************************************************************</span>
<a name="l00033"></a>00033 <span class="comment"> * OfxSecurityContainer *</span>
<a name="l00034"></a>00034 <span class="comment"> ***************************************************************************/</span>
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <a class="code" href="classOfxSecurityContainer.html#6463edacc95fc03733c0e7fb6776c15f">OfxSecurityContainer::OfxSecurityContainer</a>(<a class="code" href="classLibofxContext.html">LibofxContext</a> *p_libofx_context, <a class="code" href="classOfxGenericContainer.html" title="A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer...">OfxGenericContainer</a> *para_parentcontainer, <span class="keywordtype">string</span> para_tag_identifier):
<a name="l00037"></a>00037 <a class="code" href="classOfxGenericContainer.html" title="A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer...">OfxGenericContainer</a>(p_libofx_context, para_parentcontainer, para_tag_identifier)
<a name="l00038"></a>00038 {
<a name="l00039"></a>00039 memset(&<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>,0,<span class="keyword">sizeof</span>(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>));
<a name="l00040"></a>00040 <a class="code" href="classOfxGenericContainer.html#2cad6fe32c79d320b8808d1e88b4e18a">type</a>=<span class="stringliteral">"SECURITY"</span>;
<a name="l00041"></a>00041 }
<a name="l00042"></a>00042 <a class="code" href="classOfxSecurityContainer.html#5205f0a09177451b4a6420da7420c256">OfxSecurityContainer::~OfxSecurityContainer</a>()
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 <span class="keywordtype">void</span> <a class="code" href="classOfxSecurityContainer.html#97f5d5e139d4cbba9790bedc06fa156e" title="Add data to a container object.">OfxSecurityContainer::add_attribute</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> identifier, <span class="keyword">const</span> <span class="keywordtype">string</span> value)
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047 <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"UNIQUEID"</span>){
<a name="l00048"></a>00048 strncpy(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#1ad6b3667ca3ee7e3b3685e63c8bd1c6">unique_id</a>,value.c_str(), <span class="keyword">sizeof</span>(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#1ad6b3667ca3ee7e3b3685e63c8bd1c6">unique_id</a>));
<a name="l00049"></a>00049 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#a7ecd355d7f19287032fe54395a28a62">unique_id_valid</a> = <span class="keyword">true</span>;
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"UNIQUEIDTYPE"</span>){
<a name="l00052"></a>00052 strncpy(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#fddec0de534d0ab20cfd3ac562258615">unique_id_type</a>,value.c_str(), <span class="keyword">sizeof</span>(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#fddec0de534d0ab20cfd3ac562258615">unique_id_type</a>));
<a name="l00053"></a>00053 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#4dd2110777af7a80bdedc2775afa4415">unique_id_type_valid</a> = <span class="keyword">true</span>;
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"SECNAME"</span>){
<a name="l00056"></a>00056 strncpy(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#24096ad3cb35be8e6adb626b23f45a83">secname</a>,value.c_str(), <span class="keyword">sizeof</span>(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#24096ad3cb35be8e6adb626b23f45a83">secname</a>));
<a name="l00057"></a>00057 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#52b1cc129ff42506f38d361a91aa6b3b">secname_valid</a> = <span class="keyword">true</span>;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"TICKER"</span>){
<a name="l00060"></a>00060 strncpy(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#7d1091abe3015294844107a6c3d27da2">ticker</a>,value.c_str(), <span class="keyword">sizeof</span>(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#7d1091abe3015294844107a6c3d27da2">ticker</a>));
<a name="l00061"></a>00061 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#70920a7c4c7db99ab3fdff9a69be1dcc">ticker_valid</a> = <span class="keyword">true</span>;
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"UNITPRICE"</span>){
<a name="l00064"></a>00064 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#b7e970b0d2efb4afd77e5140f6377eea">unitprice</a>=<a class="code" href="ofx__utilities_8cpp.html#bfca5b423e5d7b194eb53c53f706f6ba" title="Convert OFX amount of money to double float.">ofxamount_to_double</a>(value);
<a name="l00065"></a>00065 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#0393e16cd2a2e36ab3c08274eb3d2e4b">unitprice_valid</a> = <span class="keyword">true</span>;
<a name="l00066"></a>00066 }
<a name="l00067"></a>00067 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"DTASOF"</span>){
<a name="l00068"></a>00068 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#39f70a97d1390f293a9726a014ed5736">date_unitprice</a> = <a class="code" href="ofx__utilities_8cpp.html#5fdbbc08f8d80a534f8db03d25316d7a" title="Convert a C++ string containing a time in OFX format to a C time_t.">ofxdate_to_time_t</a>(value);
<a name="l00069"></a>00069 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#d4cd155f29e20ebc3e85de05f6178510">date_unitprice_valid</a> = <span class="keyword">true</span>;
<a name="l00070"></a>00070 }
<a name="l00071"></a>00071 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"CURDEF"</span>){
<a name="l00072"></a>00072 strncpy(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#02b3d96724074884948651a394897c95">currency</a>,value.c_str(),<a class="code" href="inc_2libofx_8h.html#bb7701460acb587f9113ccf818b567ad">OFX_CURRENCY_LENGTH</a>);
<a name="l00073"></a>00073 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#2d16df55fa63534c4d4d7a5c804e9fb6">currency_valid</a>=<span class="keyword">true</span>;
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(identifier==<span class="stringliteral">"MEMO"</span> || identifier==<span class="stringliteral">"MEMO2"</span>){
<a name="l00076"></a>00076 strncpy(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#097572b1667a4e859fd34578aee8cdd8">memo</a>,value.c_str(), <span class="keyword">sizeof</span>(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#097572b1667a4e859fd34578aee8cdd8">memo</a>));
<a name="l00077"></a>00077 <a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>.<a class="code" href="structOfxSecurityData.html#3b21ccb14b1e6cd0c23d5587e7ce51c1">memo_valid</a> = <span class="keyword">true</span>;
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079 <span class="keywordflow">else</span>{
<a name="l00080"></a>00080 <span class="comment">/* Redirect unknown identifiers to the base class */</span>
<a name="l00081"></a>00081 <a class="code" href="classOfxGenericContainer.html#6168716a931dc8e74bcb534fdadaf778" title="Add data to a container object.">OfxGenericContainer::add_attribute</a>(identifier, value);
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 <span class="keywordtype">int</span> <a class="code" href="classOfxSecurityContainer.html#22357ade2036de78947ac0cc0ce01f2d" title="Generate libofx.h events.">OfxSecurityContainer::gen_event</a>()
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086 <a class="code" href="classOfxGenericContainer.html#a2d199f4cd2a723ea2c935e83fbc340d">libofx_context</a>-><a class="code" href="classLibofxContext.html#7475e62f44e4e9351f193697956d88cd">securityCallback</a>(<a class="code" href="classOfxSecurityContainer.html#43397c78bdf1a342ca566e7524d36f0d">data</a>);
<a name="l00087"></a>00087 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00088"></a>00088 }
<a name="l00089"></a>00089
<a name="l00090"></a>00090 <span class="keywordtype">int</span> <a class="code" href="classOfxSecurityContainer.html#cbaa6366a60d903ee3b3748c9874157f" title="Add this container to the main tree.">OfxSecurityContainer::add_to_main_tree</a>()
<a name="l00091"></a>00091 {
<a name="l00092"></a>00092 <span class="keywordflow">if</span>(MainContainer != NULL)
<a name="l00093"></a>00093 {
<a name="l00094"></a>00094 <span class="keywordflow">return</span> MainContainer-><a class="code" href="classOfxMainContainer.html#bf9596f27e1f2382fe6f1054d2a00e1d">add_container</a>(<span class="keyword">this</span>);
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 <span class="keywordflow">else</span>
<a name="l00097"></a>00097 {
<a name="l00098"></a>00098 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101
</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Mon Nov 19 20:27:59 2007 for LibOFX by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>
|