Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy   
 

/home/orenmnero/autobuild/quickfix/src/C++/Settings.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (c) quickfixengine.org  All rights reserved.
00003 **
00004 ** This file is part of the QuickFIX FIX Engine
00005 **
00006 ** This file may be distributed under the terms of the quickfixengine.org
00007 ** license as defined by quickfixengine.org and appearing in the file
00008 ** LICENSE included in the packaging of this file.
00009 **
00010 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00011 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00012 **
00013 ** See http://www.quickfixengine.org/LICENSE for licensing information.
00014 **
00015 ** Contact ask@quickfixengine.org if any conditions of this licensing are
00016 ** not clear to you.
00017 **
00018 ****************************************************************************/
00019 
00020 #ifdef _MSC_VER
00021 #include "stdafx.h"
00022 #else
00023 #include "config.h"
00024 #endif
00025 #include "CallStack.h"
00026 
00027 #include "Settings.h"
00028 #include "ConfigLexer.h"
00029 
00030 namespace FIX
00031 {
00032 std::istream& operator>>( std::istream& stream, Settings& s )
00033 {
00034   ConfigLexer lexer( &stream );
00035   int lcState = 0;
00036   Settings::Sections::iterator currentSection = s.m_sections.end();
00037   std::string currentName;
00038   while ( 0 != ( lcState = lexer.yylex() ) )
00039   {
00040     switch ( lcState )
00041     {
00042       case ConfigLexer::LC_STATE_SECTION:
00043       currentSection = s.m_sections.insert
00044                        ( s.m_sections.end(),
00045                          Dictionary( lexer.YYText() ) );
00046       break;
00047       case ConfigLexer::LC_STATE_NAME:
00048       currentName = lexer.YYText();
00049       break;
00050       case ConfigLexer::LC_STATE_VALUE:
00051       std::string value = lexer.YYText();
00052       std::string::size_type pos = value.find_last_not_of( ' ' );
00053       if ( pos == std::string::npos ) continue;
00054       value.resize( pos + 1 );
00055       ( *currentSection ).setString( currentName, value );
00056       break;
00057     }
00058   }
00059   return stream;
00060 }
00061 
00062 Settings::Sections Settings::get( std::string name ) const
00063 { QF_STACK_PUSH(Settings::get)
00064 
00065   Sections sections;
00066   for ( Sections::size_type i = 0; i < m_sections.size(); ++i )
00067     if ( m_sections[ i ].getName() == name )
00068       sections.push_back( m_sections[ i ] );
00069   return sections;
00070 
00071   QF_STACK_POP
00072 }
00073 }

Generated on Mon Jul 24 19:36:30 2006 for QuickFIX by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2001