Skip to content

Commit dca88bb

Browse files
feat: more toString, minor cleanup
1 parent 2aaa1c5 commit dca88bb

33 files changed

+170
-91
lines changed

.github/workflows/doxygen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy Doxygen page
22
on:
33
push:
44
branches:
5-
- pr/rewrite
5+
- main
66

77
permissions:
88
contents: read

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION VERSION 3.30)
2-
project(JavaObjectStreams VERSION 1.3.3)
2+
project(JavaObjectStreams VERSION 1.3.4)
33

44
set(CMAKE_CXX_STANDARD 20)
55

@@ -145,6 +145,10 @@ target_include_directories(JavaObjectStreams
145145
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
146146
)
147147

148+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
149+
target_compile_definitions(JavaObjectStreams PRIVATE DEBUG)
150+
endif ()
151+
148152
target_link_libraries(JavaObjectStreams PUBLIC bio-cpp20)
149153

150154
option(JAVAOBJECTSTREAMS_BUILD_TESTS "Build JavaObjectStreams Tests" ON)

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
<div align="right">
1+
# JavaObjectStreams
22

33
[![GitHub tag](https://img.shields.io/github/tag/Team-Lodestone/JavaObjectStreams?include_prereleases=&sort=semver&color=blue)](https://github.com/Team-Lodestone/JavaObjectStreams/releases/)
44
[![License](https://img.shields.io/badge/License-MIT-blue)](#license)
55

6-
</div>
7-
8-
# JavaObjectStreams
6+
[![Read the docs](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/documentation/ghpages_vector.svg)](https://team-lodestone.github.io/JavaObjectStreams/ "Go to project documentation")
97

108
A C++ library to provide serialization and deserialization of Java objects (ala ObjectInputStream and ObjectOutputStream).
119

12-
[![view - Documentation](https://img.shields.io/badge/view-Documentation-blue?style=for-the-badge)](https://team-lodestone.github.io/JavaObjectStreams/ "Go to project documentation")
13-
1410
### JavaObjectStreams is not...
1511
- a Java class file parser.
1612
- a Java disassembler.
1713

1814
---
1915

20-
- ✅ Deserialization
21-
- ❌ Serialization (TODO)
16+
| | [V2](https://docs.oracle.com/javase/9/docs/specs/serialization/protocol.html#stream-protocol-versions) | [V1](https://docs.oracle.com/javase/9/docs/specs/serialization/protocol.html#stream-protocol-versions) |
17+
|:-------------------:|:------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------:|
18+
| **Deserialization** |||
19+
| **Serialization** |||
2220

2321
## Contributing
2422
Unless otherwise stated, contributions are licensed under the terms of the

include/JavaObject/EObjectTypeCode.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @file EJavaTypeCode.h
1+
/** @file EObjectTypeCode.h
22
*
33
* @author DexrnZacAttack
44
* @date 3/23/26
@@ -8,8 +8,8 @@
88
* @copyright Copyright (c) 2026 Team Lodestone
99
* @license This project is licensed under the MIT license, see the LICENSE file for details.
1010
*/
11-
#ifndef JAVAOBJECTSTREAMS_EJAVATYPECODE_H
12-
#define JAVAOBJECTSTREAMS_EJAVATYPECODE_H
11+
#ifndef JAVAOBJECTSTREAMS_EOBJECTTYPECODE_H
12+
#define JAVAOBJECTSTREAMS_EOBJECTTYPECODE_H
1313

1414
enum class EObjectTypeCode : signed char {
1515
TC_NULL = 0x70,
@@ -32,4 +32,4 @@ enum class EObjectTypeCode : signed char {
3232
TC_MAX = TC_ENUM // highest value
3333
};
3434

35-
#endif // JAVAOBJECTSTREAMS_EJAVATYPECODE_H
35+
#endif // JAVAOBJECTSTREAMS_EOBJECTTYPECODE_H
Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,61 @@
1-
/** @file EJavaFieldDescriptorType.h
1+
/** @file EPrimitiveTypeCode.h
22
*
33
* @author DexrnZacAttack
44
* @date 3/23/26
5-
*
5+
*
66
* @device zPc-i2
77
*
88
* @copyright Copyright (c) 2026 Team Lodestone
99
* @license This project is licensed under the MIT license, see the LICENSE file for details.
1010
*/
11-
#ifndef JAVAOBJECTSTREAMS_EJAVAFIELDDESCRIPTORTYPE_H
12-
#define JAVAOBJECTSTREAMS_EJAVAFIELDDESCRIPTORTYPE_H
11+
#ifndef JAVAOBJECTSTREAMS_EPRIMITIVETYPECODE_H
12+
#define JAVAOBJECTSTREAMS_EPRIMITIVETYPECODE_H
13+
#include <format>
1314

1415
enum class EPrimitiveTypeCode : signed char {
15-
TYPE_BYTE = 'B',
16-
TYPE_CHARACTER = 'C',
17-
TYPE_DOUBLE = 'D',
18-
TYPE_FLOAT = 'F',
19-
TYPE_INT = 'I',
20-
TYPE_LONG = 'J',
21-
TYPE_OBJECT = 'L',
22-
TYPE_SHORT = 'S',
23-
TYPE_BOOLEAN = 'Z',
24-
TYPE_ARRAY = '['
16+
TYPE_BYTE = 'B',
17+
TYPE_CHARACTER = 'C',
18+
TYPE_DOUBLE = 'D',
19+
TYPE_FLOAT = 'F',
20+
TYPE_INT = 'I',
21+
TYPE_LONG = 'J',
22+
TYPE_OBJECT = 'L',
23+
TYPE_SHORT = 'S',
24+
TYPE_BOOLEAN = 'Z',
25+
TYPE_ARRAY = '['
26+
};
27+
28+
static constexpr const char *primitiveTypeCodeToString(const EPrimitiveTypeCode tc) {
29+
switch (tc) {
30+
case EPrimitiveTypeCode::TYPE_BYTE:
31+
return "Byte";
32+
case EPrimitiveTypeCode::TYPE_CHARACTER:
33+
return "Character";
34+
case EPrimitiveTypeCode::TYPE_DOUBLE:
35+
return "Double";
36+
case EPrimitiveTypeCode::TYPE_FLOAT:
37+
return "Float";
38+
case EPrimitiveTypeCode::TYPE_INT:
39+
return "Integer";
40+
case EPrimitiveTypeCode::TYPE_LONG:
41+
return "Long";
42+
case EPrimitiveTypeCode::TYPE_OBJECT:
43+
return "Object";
44+
case EPrimitiveTypeCode::TYPE_SHORT:
45+
return "Short";
46+
case EPrimitiveTypeCode::TYPE_BOOLEAN:
47+
return "Boolean";
48+
case EPrimitiveTypeCode::TYPE_ARRAY:
49+
return "Array";
50+
default:
51+
throw std::invalid_argument("not valid EPrimitiveTypeCode");
52+
}
53+
}
54+
55+
template <> struct std::formatter<EPrimitiveTypeCode> {
56+
template <typename FormatParseContext> constexpr auto parse(FormatParseContext &pc) { return pc.begin(); }
57+
58+
template <typename FormatContext> auto format(EPrimitiveTypeCode tc, FormatContext &fc) const { return std::format_to(fc.out(), "{}", primitiveTypeCodeToString(tc)); }
2559
};
2660

27-
#endif // JAVAOBJECTSTREAMS_EJAVAFIELDDESCRIPTORTYPE_H
61+
#endif // JAVAOBJECTSTREAMS_EPRIMITIVETYPECODE_H

include/JavaObject/stream/ObjectInputStream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111
#ifndef JAVAOBJECTSTREAMS_OBJECTINPUTSTREAM_H
1212
#define JAVAOBJECTSTREAMS_OBJECTINPUTSTREAM_H
13-
#include "../type/object/ObjectTypeCodeParser.h"
14-
#include "../type/object/types/IObject.h"
13+
#include "JavaObject/type/object/ObjectTypeCodeParser.h"
14+
#include "JavaObject/type/object/types/IObject.h"
1515

1616
#include <iostream>
1717
#include <memory>

include/JavaObject/type/ITypeCodeStorageHolder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* @copyright Copyright (c) 2026 Team Lodestone
99
* @license This project is licensed under the LGPL 3.0 license, see the LICENSE file for details.
1010
*/
11-
#ifndef PROJECTLODESTONE_ITYPECODESTORAGEHOLDER_H
12-
#define PROJECTLODESTONE_ITYPECODESTORAGEHOLDER_H
11+
#ifndef JAVAOBJECTSTREAMS_ITYPECODESTORAGEHOLDER_H
12+
#define JAVAOBJECTSTREAMS_ITYPECODESTORAGEHOLDER_H
1313
#include "TypeCodeParserStorage.h"
1414

1515
namespace javaobject::type {
@@ -24,4 +24,4 @@ namespace javaobject::type {
2424
};
2525
}
2626

27-
#endif //PROJECTLODESTONE_ITYPECODESTORAGEHOLDER_H
27+
#endif //JAVAOBJECTSTREAMS_ITYPECODESTORAGEHOLDER_H

include/JavaObject/type/TypeCodeParserStorage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* @copyright Copyright (c) 2026 Team Lodestone
99
* @license This project is licensed under the LGPL 3.0 license, see the LICENSE file for details.
1010
*/
11-
#ifndef PROJECTLODESTONE_TYPECODESTORAGE_H
12-
#define PROJECTLODESTONE_TYPECODESTORAGE_H
11+
#ifndef JAVAOBJECTSTREAMS_TYPECODESTORAGE_H
12+
#define JAVAOBJECTSTREAMS_TYPECODESTORAGE_H
1313
#include <memory>
1414

1515

@@ -28,4 +28,4 @@ namespace javaobject::type {
2828
};
2929
}
3030

31-
#endif //PROJECTLODESTONE_TYPECODESTORAGE_H
31+
#endif //JAVAOBJECTSTREAMS_TYPECODESTORAGE_H

include/JavaObject/type/object/ObjectTypeCodeParser.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @file TypeCode.h
1+
/** @file ObjectTypeCodeParser.h
22
*
33
* @author DexrnZacAttack
44
* @date 3/24/26
@@ -7,20 +7,13 @@
77
*/
88
#ifndef JAVAOBJECTSTREAMS_TYPECODE_H
99
#define JAVAOBJECTSTREAMS_TYPECODE_H
10-
#include "BinaryIO/stream/BinaryInputStream.h"
1110
#include "JavaObject/EObjectTypeCode.h"
1211
#include "JavaObject/type/HandleContainer.h"
1312
#include "JavaObject/type/ITypeCodeParser.h"
1413
#include "JavaObject/type/object/parsers/IObjectParser.h"
15-
#include "JavaObject/type/object/parsers/ReferenceParser.h"
16-
#include "JavaObject/util/SmartPointerCast.h"
17-
#include "types/ReferenceObject.h"
1814

19-
#include <functional>
2015
#include <iosfwd>
2116
#include <memory>
22-
#include <unordered_map>
23-
#include <variant>
2417

2518
#include "JavaObject/type/ITypeCodeStorageHolder.h"
2619

include/JavaObject/type/object/parsers/NewClassParser.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@
1111
#ifndef JAVAOBJECTSTREAMS_NEWCLASSPARSER_H
1212
#define JAVAOBJECTSTREAMS_NEWCLASSPARSER_H
1313

14-
namespace javaobject {
15-
namespace type {
16-
namespace parser {
17-
class NewClassParser {};
18-
} // namespace parser
19-
} // namespace type
20-
} // namespace javaobject
14+
namespace javaobject::type::parser {
15+
class NewClassParser {};
16+
} // namespace javaobject::type::parser
2117

2218
#endif // JAVAOBJECTSTREAMS_NEWCLASSPARSER_H

0 commit comments

Comments
 (0)