Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
0ceb1987
Commit
0ceb1987
authored
Aug 11, 2010
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement OUTPUTFORMATTER::Quoted()
parent
0980306f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
12 deletions
+51
-12
richio.cpp
common/richio.cpp
+40
-0
xnode.cpp
common/xnode.cpp
+3
-6
netform.cpp
eeschema/netform.cpp
+2
-2
netlist_form_pads-pcb.xsl
eeschema/plugins/netlist_form_pads-pcb.xsl
+1
-1
richio.h
include/richio.h
+5
-3
No files found.
common/richio.cpp
View file @
0ceb1987
...
@@ -204,6 +204,46 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IOError
...
@@ -204,6 +204,46 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IOError
}
}
const
char
*
OUTPUTFORMATTER
::
Quoted
(
std
::
string
*
aWrapee
)
throw
(
IOError
)
{
// derived class's notion of what a quote character is
char
quote
=
*
GetQuoteChar
(
"("
);
// Will the string be wrapped based on its interior content?
const
char
*
squote
=
GetQuoteChar
(
aWrapee
->
c_str
()
);
// Search the interior of the string for 'quote' chars
// and replace them as found with duplicated quotes.
// Note that necessarily any string which has internal quotes will
// also be wrapped in quotes later in this function.
for
(
unsigned
i
=
0
;
i
<
aWrapee
->
size
();
++
i
)
{
if
(
(
*
aWrapee
)[
i
]
==
quote
)
{
aWrapee
->
insert
(
aWrapee
->
begin
()
+
i
,
quote
);
++
i
;
}
else
if
(
(
*
aWrapee
)[
0
]
==
'\r'
||
(
*
aWrapee
)[
0
]
==
'\n'
)
{
// In a desire to maintain accurate line number reporting within DSNLEXER
// a decision was made to make all S-expression strings be on a single
// line. You can embedd \n (human readable) in the text but not
// '\n' which is 0x0a.
throw
IOError
(
_
(
"S-expression string has newline"
)
);
}
}
if
(
*
squote
)
{
// wrap the beginning and end of the string in a quote.
aWrapee
->
insert
(
aWrapee
->
begin
(),
quote
);
aWrapee
->
insert
(
aWrapee
->
end
(),
quote
);
}
return
aWrapee
->
c_str
();
}
//-----<STRING_FORMATTER>----------------------------------------------------
//-----<STRING_FORMATTER>----------------------------------------------------
void
STRING_FORMATTER
::
write
(
const
char
*
aOutBuf
,
int
aCount
)
throw
(
IOError
)
void
STRING_FORMATTER
::
write
(
const
char
*
aOutBuf
,
int
aCount
)
throw
(
IOError
)
...
...
common/xnode.cpp
View file @
0ceb1987
...
@@ -51,18 +51,16 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
...
@@ -51,18 +51,16 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
void
XNODE
::
FormatContents
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
throw
(
IOError
)
void
XNODE
::
FormatContents
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
throw
(
IOError
)
{
{
std
::
string
utf8
;
std
::
string
utf8
;
const
char
*
quote
;
// output attributes first if they exist
// output attributes first if they exist
for
(
XATTR
*
attr
=
(
XATTR
*
)
GetAttributes
();
attr
;
attr
=
(
XATTR
*
)
attr
->
GetNext
()
)
for
(
XATTR
*
attr
=
(
XATTR
*
)
GetAttributes
();
attr
;
attr
=
(
XATTR
*
)
attr
->
GetNext
()
)
{
{
utf8
=
CONV_TO_UTF8
(
attr
->
GetValue
()
);
// capture the content
utf8
=
CONV_TO_UTF8
(
attr
->
GetValue
()
);
// capture the content
quote
=
out
->
GetQuoteChar
(
utf8
.
c_str
()
);
out
->
Print
(
0
,
" (%s %s
%s%s
)"
,
out
->
Print
(
0
,
" (%s %s)"
,
// attr names should never need quoting, no spaces, we designed the file.
// attr names should never need quoting, no spaces, we designed the file.
CONV_TO_UTF8
(
attr
->
GetName
()
),
CONV_TO_UTF8
(
attr
->
GetName
()
),
quote
,
utf8
.
c_str
(),
quote
);
out
->
Quoted
(
&
utf8
)
);
}
}
// we only expect to have used one of two types here:
// we only expect to have used one of two types here:
...
@@ -88,8 +86,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError
...
@@ -88,8 +86,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError
case
wxXML_TEXT_NODE
:
case
wxXML_TEXT_NODE
:
utf8
=
CONV_TO_UTF8
(
GetContent
()
);
utf8
=
CONV_TO_UTF8
(
GetContent
()
);
quote
=
out
->
GetQuoteChar
(
utf8
.
c_str
()
);
out
->
Print
(
0
,
" %s"
,
out
->
Quoted
(
&
utf8
)
);
out
->
Print
(
0
,
" %s%s%s"
,
quote
,
utf8
.
c_str
(),
quote
);
break
;
break
;
default
:
default
:
...
...
eeschema/netform.cpp
View file @
0ceb1987
...
@@ -1010,7 +1010,7 @@ XNODE* EXPORT_HELP::makeGenericComponents()
...
@@ -1010,7 +1010,7 @@ XNODE* EXPORT_HELP::makeGenericComponents()
bool
EXPORT_HELP
::
WriteGENERICNetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
aOutFileName
)
bool
EXPORT_HELP
::
WriteGENERICNetList
(
WinEDA_SchematicFrame
*
frame
,
const
wxString
&
aOutFileName
)
{
{
#if
0
#if
1
// this code seems to work now, for S-expression support.
// this code seems to work now, for S-expression support.
...
...
eeschema/plugins/netlist_form_pads-pcb.xsl
View file @
0ceb1987
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<xsl:stylesheet
version=
"1.0"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
>
<xsl:stylesheet
version=
"1.0"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
>
<xsl:output
method=
"text"
omit-xml-declaration=
"yes"
indent=
"no"
/>
<xsl:output
method=
"text"
omit-xml-declaration=
"yes"
indent=
"no"
/>
<xsl:template
match=
"export"
>
<xsl:template
match=
"
/
export"
>
<xsl:text>
*PADS-PCB*
&nl;
*PART*
&nl;
</xsl:text>
<xsl:text>
*PADS-PCB*
&nl;
*PART*
&nl;
</xsl:text>
<xsl:apply-templates
select=
"components/comp"
/>
<xsl:apply-templates
select=
"components/comp"
/>
<xsl:text>
&nl;
*NET*
&nl;
</xsl:text>
<xsl:text>
&nl;
*NET*
&nl;
</xsl:text>
...
...
include/richio.h
View file @
0ceb1987
...
@@ -301,7 +301,7 @@ public:
...
@@ -301,7 +301,7 @@ public:
/**
/**
* Function Quoted
* Function Quoted
* checks \a aWrap
p
ee input string for a need to be quoted
* checks \a aWrapee input string for a need to be quoted
* (e.g. contains a ')' character or a space), and for \" double quotes
* (e.g. contains a ')' character or a space), and for \" double quotes
* within the string that need to be doubled up such that the DSNLEXER
* within the string that need to be doubled up such that the DSNLEXER
* will correctly parse the string from a file later.
* will correctly parse the string from a file later.
...
@@ -312,9 +312,11 @@ public:
...
@@ -312,9 +312,11 @@ public:
*
*
* @return const char* - useful for passing to printf() style functions that
* @return const char* - useful for passing to printf() style functions that
* must output utf8 streams.
* must output utf8 streams.
virtual const char* Quoted( std::string* aWrapee );
* @throw IOError, if aWrapee has any \r or \n bytes in it which is
thinking about using wxCharBuffer* instead.
* illegal according to the DSNLEXER who does not ever want them
* within a string.
*/
*/
virtual
const
char
*
Quoted
(
std
::
string
*
aWrapee
)
throw
(
IOError
);
//-----</interface functions>-----------------------------------------
//-----</interface functions>-----------------------------------------
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment