OpenWalnut  1.4.0
WProjectFileIO.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <vector>
26 #include <string>
27 
28 #include "WLogger.h"
29 
30 #include "../kernel/WProjectFile.h"
31 
32 #include "WProjectFileIO.h"
33 
35  m_errors(),
36  m_applyOrder( POST_MODULES )
37 {
38  // initialize
39 }
40 
42 {
43  // cleanup!
44 }
45 
47 {
48  // do nothing here. Overwrite this method if your specific parser needs to do some post processing.
49 }
50 
52 {
53  return m_errors.size();
54 }
55 
56 const std::vector< std::string >& WProjectFileIO::getErrors() const
57 {
58  return m_errors;
59 }
60 
62 {
63  return m_warnings.size();
64 }
65 
66 const std::vector< std::string >& WProjectFileIO::getWarnings() const
67 {
68  return m_warnings;
69 }
70 
71 void WProjectFileIO::addError( std::string description )
72 {
73  wlog::error( "Project Loader" ) << description;
74  m_errors.push_back( description );
75 }
76 
77 void WProjectFileIO::addWarning( std::string description )
78 {
79  wlog::warn( "Project Loader" ) << description;
80  m_warnings.push_back( description );
81 }
82 
83 void WProjectFileIO::printProperties( std::ostream& output, boost::shared_ptr< WProperties > props, std::string indent, //NOLINT
84  std::string prefix, unsigned int index, std::string indexPrefix )
85 {
86  // lock, unlocked if l looses focus
88 
89  output << indent << "// Property Group: " << props->getName() << std::endl;
90 
91  // iterate of them and print them to output
92  for( WProperties::PropertyConstIterator iter = l->get().begin(); iter != l->get().end(); ++iter )
93  {
94  // information properties do not get written
95  if( ( *iter )->getPurpose () == PV_PURPOSE_INFORMATION )
96  {
97  continue;
98  }
99  if( ( *iter )->getType() != PV_GROUP )
100  {
101  output << indent + " " << "PROPERTY:(" << indexPrefix << index << "," << prefix + ( *iter )->getName() << ")="
102  << ( *iter )->getAsString() << std::endl;
103  }
104  else
105  {
106  // it is a group -> recursively print it
107  if( prefix.empty() )
108  {
109  printProperties( output, ( *iter )->toPropGroup(), indent + " ", ( *iter )->getName() + "/", index, indexPrefix );
110  }
111  else
112  {
113  printProperties( output, ( *iter )->toPropGroup(), indent + " ", prefix + ( *iter )->getName() + "/", index, indexPrefix );
114  }
115  }
116  }
117 
118  output << indent << "// Property Group END: " << props->getName() << std::endl;
119 }
120 
122 {
123  m_project = project;
124 }
125 
127 {
128  return m_project;
129 }
130 
132 {
133  return m_applyOrder;
134 }
135 
137 {
138  m_applyOrder = order;
139 }
140