KiCad PCB EDA Suite
title_block.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <richio.h>
26 #include <title_block.h>
27 
28 void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
29 {
30  // Don't write the title block information if there is nothing to write.
31  bool isempty = true;
32  for( unsigned idx = 0; idx < m_tbTexts.GetCount(); idx++ )
33  {
34  if( ! m_tbTexts[idx].IsEmpty() )
35  {
36  isempty = false;
37  break;
38  }
39  }
40 
41  if( !isempty )
42  {
43  aFormatter->Print( aNestLevel, "(title_block\n" );
44 
45  if( !GetTitle().IsEmpty() )
46  aFormatter->Print( aNestLevel+1, "(title %s)\n",
47  aFormatter->Quotew( GetTitle() ).c_str() );
48 
49  if( !GetDate().IsEmpty() )
50  aFormatter->Print( aNestLevel+1, "(date %s)\n",
51  aFormatter->Quotew( GetDate() ).c_str() );
52 
53  if( !GetRevision().IsEmpty() )
54  aFormatter->Print( aNestLevel+1, "(rev %s)\n",
55  aFormatter->Quotew( GetRevision() ).c_str() );
56 
57  if( !GetCompany().IsEmpty() )
58  aFormatter->Print( aNestLevel+1, "(company %s)\n",
59  aFormatter->Quotew( GetCompany() ).c_str() );
60 
61  for( int ii = 0; ii < 9; ii++ )
62  {
63  if( !GetComment(ii).IsEmpty() )
64  aFormatter->Print( aNestLevel+1, "(comment %d %s)\n", ii+1,
65  aFormatter->Quotew( GetComment(ii) ).c_str() );
66  }
67 
68  aFormatter->Print( aNestLevel, ")\n\n" );
69  }
70 }
const wxString & GetComment(int aIdx) const
Definition: title_block.h:110
OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a convenient ...
Definition: richio.h:327
wxArrayString m_tbTexts
Definition: title_block.h:133
const wxString & GetRevision() const
Definition: title_block.h:89
const wxString & GetCompany() const
Definition: title_block.h:99
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function Format outputs the object to aFormatter in s-expression form.
Definition: title_block.cpp:28
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
const wxString & GetDate() const
Definition: title_block.h:79
const wxString & GetTitle() const
Definition: title_block.h:65
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404