AirInv Logo  1.00.0
C++ Simulated Airline Inventory Management System library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InventoryParser.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
8 #include <stdair/basic/BasFileMgr.hpp>
9 #include <stdair/bom/BomRoot.hpp>
10 #include <stdair/service/Logger.hpp>
11 // Airinv
15 
16 namespace AIRINV {
17 
18  // //////////////////////////////////////////////////////////////////////
20  buildInventory (const InventoryFilePath& iInventoryFilename,
21  stdair::BomRoot& ioBomRoot) {
22 
23  const stdair::Filename_T lFilename = iInventoryFilename.name();
24 
25  // Check that the file path given as input corresponds to an actual file
26  const bool doesExistAndIsReadable =
27  stdair::BasFileMgr::doesExistAndIsReadable (lFilename);
28  if (doesExistAndIsReadable == false) {
29  std::ostringstream oMessage;
30  oMessage << "The inventory input file, '" << lFilename
31  << "', can not be retrieved on the file-system";
32  STDAIR_LOG_ERROR (oMessage.str());
33  throw InventoryInputFileNotFoundException (oMessage.str());
34  }
35 
36  // Initialise the inventory file parser.
37  InventoryFileParser lInventoryParser (ioBomRoot, lFilename);
38 
39  // Parse the CSV-formatted inventory input file, and generate the
40  // corresponding Inventory-related objects.
41  lInventoryParser.buildInventory();
42  }
43 
44 }