Skip to content

Commit 0b792e1

Browse files
committed
'arioso' example is implemented
1 parent f299a2b commit 0b792e1

File tree

9 files changed

+471
-112
lines changed

9 files changed

+471
-112
lines changed

.vscode/launch.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
"environment": [],
3939
"console": "externalTerminal"
4040
},
41+
{
42+
"name": "arioso (Windows)",
43+
"type": "cppvsdbg",
44+
"request": "launch",
45+
"program": "${workspaceFolder}/build/examples/arioso/Debug/arioso.exe",
46+
"args": ["${workspaceFolder}/build/tests/ario/simple_text.a", "-e", "hello.c", "-d", "hello.c", "-a", "hello.c"],
47+
"stopAtEntry": false,
48+
"cwd": "${workspaceFolder}/build/examples/arioso",
49+
"environment": [],
50+
"console": "externalTerminal"
51+
},
4152
{
4253
"name": "Run ELF Dump",
4354
"type": "cppdbg",

.vscode/settings.json

Lines changed: 130 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,131 @@
11
{
2-
"files.associations": {
3-
"copyright": "json",
4-
"*.ipp": "cpp",
5-
"strstream": "cpp",
6-
"cerrno": "cpp",
7-
"csetjmp": "cpp",
8-
"cstdarg": "cpp",
9-
"rope": "cpp",
10-
"iostream": "cpp",
11-
"streambuf": "cpp",
12-
"*.tcc": "cpp",
13-
"regex": "cpp",
14-
"algorithm": "cpp",
15-
"array": "cpp",
16-
"atomic": "cpp",
17-
"bit": "cpp",
18-
"bitset": "cpp",
19-
"cassert": "cpp",
20-
"cctype": "cpp",
21-
"cfloat": "cpp",
22-
"chrono": "cpp",
23-
"ciso646": "cpp",
24-
"climits": "cpp",
25-
"clocale": "cpp",
26-
"cmath": "cpp",
27-
"complex": "cpp",
28-
"cstddef": "cpp",
29-
"cstdint": "cpp",
30-
"cstdio": "cpp",
31-
"cstdlib": "cpp",
32-
"cstring": "cpp",
33-
"ctime": "cpp",
34-
"cwchar": "cpp",
35-
"cwctype": "cpp",
36-
"deque": "cpp",
37-
"list": "cpp",
38-
"map": "cpp",
39-
"set": "cpp",
40-
"string": "cpp",
41-
"unordered_map": "cpp",
42-
"vector": "cpp",
43-
"exception": "cpp",
44-
"functional": "cpp",
45-
"iterator": "cpp",
46-
"memory": "cpp",
47-
"memory_resource": "cpp",
48-
"numeric": "cpp",
49-
"optional": "cpp",
50-
"random": "cpp",
51-
"ratio": "cpp",
52-
"string_view": "cpp",
53-
"system_error": "cpp",
54-
"tuple": "cpp",
55-
"type_traits": "cpp",
56-
"utility": "cpp",
57-
"fstream": "cpp",
58-
"initializer_list": "cpp",
59-
"iomanip": "cpp",
60-
"ios": "cpp",
61-
"iosfwd": "cpp",
62-
"istream": "cpp",
63-
"limits": "cpp",
64-
"locale": "cpp",
65-
"new": "cpp",
66-
"ostream": "cpp",
67-
"queue": "cpp",
68-
"sstream": "cpp",
69-
"stdexcept": "cpp",
70-
"thread": "cpp",
71-
"cfenv": "cpp",
72-
"cinttypes": "cpp",
73-
"typeindex": "cpp",
74-
"typeinfo": "cpp",
75-
"variant": "cpp",
76-
"compare": "cpp"
77-
},
78-
"svn.ignoreMissingSvnWarning": true,
79-
"editor.tokenColorCustomizations": {
80-
"textMateRules": [
81-
{
82-
"scope": "googletest.failed",
83-
"settings": {
84-
"foreground": "#f00"
85-
}
86-
},
87-
{
88-
"scope": "googletest.passed",
89-
"settings": {
90-
"foreground": "#0f0"
91-
}
92-
},
93-
{
94-
"scope": "googletest.run",
95-
"settings": {
96-
"foreground": "#0f0"
97-
}
98-
}
99-
]
100-
},
101-
"gtest-adapter.debugConfig": "Run ELFIO Tests",
102-
"gtest-adapter.supportLocation": true,
103-
"sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json"
104-
}
2+
"files.associations": {
3+
"copyright": "json",
4+
"*.ipp": "cpp",
5+
"strstream": "cpp",
6+
"cerrno": "cpp",
7+
"csetjmp": "cpp",
8+
"cstdarg": "cpp",
9+
"rope": "cpp",
10+
"iostream": "cpp",
11+
"streambuf": "cpp",
12+
"*.tcc": "cpp",
13+
"regex": "cpp",
14+
"algorithm": "cpp",
15+
"array": "cpp",
16+
"atomic": "cpp",
17+
"bit": "cpp",
18+
"bitset": "cpp",
19+
"cassert": "cpp",
20+
"cctype": "cpp",
21+
"cfloat": "cpp",
22+
"chrono": "cpp",
23+
"ciso646": "cpp",
24+
"climits": "cpp",
25+
"clocale": "cpp",
26+
"cmath": "cpp",
27+
"complex": "cpp",
28+
"cstddef": "cpp",
29+
"cstdint": "cpp",
30+
"cstdio": "cpp",
31+
"cstdlib": "cpp",
32+
"cstring": "cpp",
33+
"ctime": "cpp",
34+
"cwchar": "cpp",
35+
"cwctype": "cpp",
36+
"deque": "cpp",
37+
"list": "cpp",
38+
"map": "cpp",
39+
"set": "cpp",
40+
"string": "cpp",
41+
"unordered_map": "cpp",
42+
"vector": "cpp",
43+
"exception": "cpp",
44+
"functional": "cpp",
45+
"iterator": "cpp",
46+
"memory": "cpp",
47+
"memory_resource": "cpp",
48+
"numeric": "cpp",
49+
"optional": "cpp",
50+
"random": "cpp",
51+
"ratio": "cpp",
52+
"string_view": "cpp",
53+
"system_error": "cpp",
54+
"tuple": "cpp",
55+
"type_traits": "cpp",
56+
"utility": "cpp",
57+
"fstream": "cpp",
58+
"initializer_list": "cpp",
59+
"iomanip": "cpp",
60+
"ios": "cpp",
61+
"iosfwd": "cpp",
62+
"istream": "cpp",
63+
"limits": "cpp",
64+
"locale": "cpp",
65+
"new": "cpp",
66+
"ostream": "cpp",
67+
"queue": "cpp",
68+
"sstream": "cpp",
69+
"stdexcept": "cpp",
70+
"thread": "cpp",
71+
"cfenv": "cpp",
72+
"cinttypes": "cpp",
73+
"typeindex": "cpp",
74+
"typeinfo": "cpp",
75+
"variant": "cpp",
76+
"compare": "cpp",
77+
"any": "cpp",
78+
"charconv": "cpp",
79+
"concepts": "cpp",
80+
"condition_variable": "cpp",
81+
"csignal": "cpp",
82+
"filesystem": "cpp",
83+
"format": "cpp",
84+
"forward_list": "cpp",
85+
"mutex": "cpp",
86+
"span": "cpp",
87+
"stop_token": "cpp",
88+
"unordered_set": "cpp",
89+
"xfacet": "cpp",
90+
"xhash": "cpp",
91+
"xiosbase": "cpp",
92+
"xlocale": "cpp",
93+
"xlocbuf": "cpp",
94+
"xlocinfo": "cpp",
95+
"xlocmes": "cpp",
96+
"xlocmon": "cpp",
97+
"xlocnum": "cpp",
98+
"xloctime": "cpp",
99+
"xmemory": "cpp",
100+
"xstring": "cpp",
101+
"xtr1common": "cpp",
102+
"xtree": "cpp",
103+
"xutility": "cpp"
104+
},
105+
"svn.ignoreMissingSvnWarning": true,
106+
"editor.tokenColorCustomizations": {
107+
"textMateRules": [
108+
{
109+
"scope": "googletest.failed",
110+
"settings": {
111+
"foreground": "#f00"
112+
}
113+
},
114+
{
115+
"scope": "googletest.passed",
116+
"settings": {
117+
"foreground": "#0f0"
118+
}
119+
},
120+
{
121+
"scope": "googletest.run",
122+
"settings": {
123+
"foreground": "#0f0"
124+
}
125+
}
126+
]
127+
},
128+
"gtest-adapter.debugConfig": "Run ELFIO Tests",
129+
"gtest-adapter.supportLocation": true,
130+
"sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json"
131+
}

ario/ario.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ class ario
105105
return data;
106106
}
107107

108+
operator std::string() const { return name; }
109+
operator std::string_view() const { return name; }
110+
operator const char*() const { return name.c_str(); }
111+
bool operator==( const std::string& name ) const
112+
{
113+
return this->name == name;
114+
}
115+
108116
protected:
109117
void set_input_stream( std::istream* pstream )
110118
{
@@ -155,7 +163,7 @@ class ario
155163
const Member& operator[]( std::string_view name ) const
156164
{
157165
for ( const auto& m : parent->members_ ) {
158-
if ( m.name == name ) {
166+
if ( m == name ) {
159167
return m;
160168
}
161169
}
@@ -381,6 +389,13 @@ class ario
381389
std::optional<std::reference_wrapper<const ario::Member>>&
382390
added_member )
383391
{
392+
// Check if the member with such name already exists
393+
for ( const auto& mem : members_ ) {
394+
if ( mem.name == member.name ) {
395+
return {"Member '" + member.name + "' already exists"};
396+
}
397+
}
398+
384399
auto& new_member = members_.emplace_back( member );
385400
new_member.size = data.size();
386401
new_member.pstream = nullptr;

examples/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ add_subdirectory(tutorial)
77
add_subdirectory(write_obj)
88
add_subdirectory(writer)
99
#add_subdirectory(c_wrapper)
10-
add_subdirectory(archive_dump)
10+
add_subdirectory(arion)
11+
add_subdirectory(arioso)

examples/archive_dump/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/arion/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
add_executable(arion arion.cpp)
3+
target_link_libraries(arion PRIVATE ario::ario)
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using namespace ARIO;
2727
int main( int argc, char** argv )
2828
{
2929
if ( argc != 2 ) {
30-
printf( "Usage: archive_dump <file_name>\n" );
30+
printf( "Usage: arion <file_name>\n" );
3131
return 1;
3232
}
3333

@@ -43,10 +43,9 @@ int main( int argc, char** argv )
4343
std::cout << "Member: " << std::setw( 40 ) << std::left << member.name
4444
<< " Size: " << std::setw( 8 ) << std::right << member.size
4545
<< " Mode: " << std::setw( 3 ) << std::oct << member.mode
46-
<< std::endl;
46+
<< std::dec << std::endl;
4747
std::vector<std::string> symbols;
48-
result = archive.get_symbols_for_member( member, symbols );
49-
if ( result.ok() ) {
48+
if ( archive.get_symbols_for_member( member, symbols ).ok() ) {
5049
auto first_time = true;
5150
for ( const auto& symbol : symbols ) {
5251
if ( first_time ) {

examples/arioso/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
add_executable(arioso arioso.cpp)
3+
target_link_libraries(arioso PRIVATE ario::ario elfio::elfio)

0 commit comments

Comments
 (0)