Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
graph-tool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
40
Issues
40
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tiago Peixoto
graph-tool
Commits
8664f7f2
Commit
8664f7f2
authored
Jun 13, 2015
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of property maps with python::object values with dot and gml formats
parent
8141f5f2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
110 additions
and
50 deletions
+110
-50
src/boost-workaround/boost/graph/graphml.hpp
src/boost-workaround/boost/graph/graphml.hpp
+3
-5
src/graph/Makefile.am
src/graph/Makefile.am
+2
-0
src/graph/base64.cc
src/graph/base64.cc
+63
-0
src/graph/base64.hh
src/graph/base64.hh
+26
-0
src/graph/gml.hh
src/graph/gml.hh
+3
-1
src/graph/graph_io.cc
src/graph/graph_io.cc
+11
-1
src/graph/graphml.cpp
src/graph/graphml.cpp
+2
-43
No files found.
src/boost-workaround/boost/graph/graphml.hpp
View file @
8664f7f2
...
...
@@ -29,14 +29,12 @@
#include <set>
#include <unordered_set>
namespace
boost
{
// Base64 Encoding
std
::
string
base64_encode
(
const
std
::
string
&
s
);
std
::
string
base64_decode
(
const
std
::
string
&
s
);
#include "base64.hh"
namespace
boost
{
/////////////////////////////////////////////////////////////////////////////
// Graph reader exceptions
...
...
src/graph/Makefile.am
View file @
8664f7f2
...
...
@@ -18,6 +18,7 @@ libgraph_tool_coredir = $(MOD_DIR)
libgraph_tool_core_LTLIBRARIES
=
libgraph_tool_core.la
libgraph_tool_core_la_SOURCES
=
\
base64.cc
\
graph.cc
\
graph_exceptions.cc
\
graph_bind.cc
\
...
...
@@ -41,6 +42,7 @@ libgraph_tool_core_la_SOURCES = \
libgraph_tool_core_la_includedir
=
$(MOD_DIR)
/include
libgraph_tool_core_la_include_HEADERS
=
\
../../config.h
\
base64.hh
\
fast_vector_property_map.hh
\
gml.hh
\
graph.hh
\
...
...
src/graph/base64.cc
0 → 100644
View file @
8664f7f2
// graph-tool -- a general graph modification and manipulation thingy
//
// Copyright (C) 2006-2015 Tiago de Paula Peixoto <tiago@skewed.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "base64.hh"
#include <sstream>
#include <boost/archive/iterators/ostream_iterator.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>
std
::
string
base64_encode
(
const
std
::
string
&
s
)
{
static
const
std
::
string
base64_padding
[]
=
{
""
,
"=="
,
"="
};
namespace
bai
=
boost
::
archive
::
iterators
;
std
::
stringstream
os
;
typedef
bai
::
base64_from_binary
<
bai
::
transform_width
<
const
char
*
,
6
,
8
>
>
base64_enc
;
std
::
copy
(
base64_enc
(
s
.
c_str
()),
base64_enc
(
s
.
c_str
()
+
s
.
size
()),
std
::
ostream_iterator
<
char
>
(
os
));
os
<<
base64_padding
[
s
.
size
()
%
3
];
return
os
.
str
();
}
std
::
string
base64_decode
(
const
std
::
string
&
s
)
{
namespace
bai
=
boost
::
archive
::
iterators
;
std
::
stringstream
os
;
typedef
bai
::
transform_width
<
bai
::
binary_from_base64
<
const
char
*>
,
8
,
6
>
base64_dec
;
unsigned
int
size
=
s
.
size
();
// Remove the padding characters, cf. https://svn.boost.org/trac/boost/ticket/5629
if
(
size
&&
s
[
size
-
1
]
==
'='
)
{
--
size
;
if
(
size
&&
s
[
size
-
1
]
==
'='
)
--
size
;
}
if
(
size
==
0
)
return
std
::
string
();
std
::
copy
(
base64_dec
(
s
.
data
()),
base64_dec
(
s
.
data
()
+
size
),
std
::
ostream_iterator
<
char
>
(
os
));
return
os
.
str
();
}
src/graph/base64.hh
0 → 100644
View file @
8664f7f2
// graph-tool -- a general graph modification and manipulation thingy
//
// Copyright (C) 2006-2015 Tiago de Paula Peixoto <tiago@skewed.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BASE64_HH
#define BASE64_HH
#include <string>
std
::
string
base64_encode
(
const
std
::
string
&
s
);
std
::
string
base64_decode
(
const
std
::
string
&
s
);
#endif
src/graph/gml.hh
View file @
8664f7f2
...
...
@@ -48,6 +48,8 @@
#include <unordered_map>
#include "base64.hh"
namespace
graph_tool
{
using
namespace
std
;
...
...
@@ -362,7 +364,7 @@ struct get_str
ValueType
v
=
any_cast
<
ValueType
>
(
val
);
if
(
std
::
is_same
<
ValueType
,
python
::
object
>::
value
)
{
sval
=
lexical_cast
<
string
>
(
v
);
sval
=
base64_encode
(
lexical_cast
<
string
>
(
v
)
);
}
else
{
...
...
src/graph/graph_io.cc
View file @
8664f7f2
...
...
@@ -25,7 +25,6 @@
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/device/file.hpp>
#include <boost/graph/graphml.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/xpressive/xpressive.hpp>
...
...
@@ -79,8 +78,19 @@ python::object lexical_cast<python::object,string>(const string& ps)
o
=
object_unpickler
(
IStream
(
s
));
return
o
;
}
namespace
python
{
std
::
ostringstream
&
operator
<<
(
std
::
ostringstream
&
stream
,
const
boost
::
python
::
object
&
o
)
{
stream
<<
base64_encode
(
lexical_cast
<
string
>
(
o
));
return
stream
;
}
}
}
#include <boost/graph/graphviz.hpp>
#include "graph_io_binary.hh"
// the following source & sink provide iostream access to python file-like
...
...
src/graph/graphml.cpp
View file @
8664f7f2
...
...
@@ -16,56 +16,15 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/archive/iterators/xml_escape.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/insert_linebreaks.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
#include <sstream>
#include "base64.hh"
using
namespace
boost
;
namespace
boost
{
std
::
string
base64_encode
(
const
std
::
string
&
s
)
{
static
const
std
::
string
base64_padding
[]
=
{
""
,
"=="
,
"="
};
namespace
bai
=
boost
::
archive
::
iterators
;
std
::
stringstream
os
;
typedef
bai
::
base64_from_binary
<
bai
::
transform_width
<
const
char
*
,
6
,
8
>
>
base64_enc
;
std
::
copy
(
base64_enc
(
s
.
c_str
()),
base64_enc
(
s
.
c_str
()
+
s
.
size
()),
std
::
ostream_iterator
<
char
>
(
os
));
os
<<
base64_padding
[
s
.
size
()
%
3
];
return
os
.
str
();
}
std
::
string
base64_decode
(
const
std
::
string
&
s
)
{
namespace
bai
=
boost
::
archive
::
iterators
;
std
::
stringstream
os
;
typedef
bai
::
transform_width
<
bai
::
binary_from_base64
<
const
char
*>
,
8
,
6
>
base64_dec
;
unsigned
int
size
=
s
.
size
();
// Remove the padding characters, cf. https://svn.boost.org/trac/boost/ticket/5629
if
(
size
&&
s
[
size
-
1
]
==
'='
)
{
--
size
;
if
(
size
&&
s
[
size
-
1
]
==
'='
)
--
size
;
}
if
(
size
==
0
)
return
std
::
string
();
std
::
copy
(
base64_dec
(
s
.
data
()),
base64_dec
(
s
.
data
()
+
size
),
std
::
ostream_iterator
<
char
>
(
os
));
return
os
.
str
();
}
std
::
string
protect_xml_string
(
const
std
::
string
&
os
)
{
using
namespace
boost
::
archive
::
iterators
;
...
...
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