cldf 1.0.0
cldf: ^1.0.0 copied to clipboard
A Dart implementation of the Crushlog Data Format (CLDF) for climbing data exchange.
CLDF - Crushlog Data Format for Dart #
A Dart implementation of the Crushlog Data Format (CLDF) for climbing data exchange.
Features #
- Read and write CLDF archives (.cldf files)
- JSON serialization/deserialization for all CLDF models
- Type-safe Dart models for all CLDF entities
- Archive creation with automatic checksums
- Validation support
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
cldf: ^1.0.0
Usage #
Reading a CLDF archive #
import 'package:cldf/cldf.dart';
final reader = CLDFReader();
final archive = await reader.readFile('path/to/file.cldf');
// Access data
print('Locations: ${archive.locations.length}');
print('Routes: ${archive.routes.length}');
print('Climbs: ${archive.climbs.length}');
Writing a CLDF archive #
import 'package:cldf/cldf.dart';
final archive = CLDFArchive(
manifest: Manifest(
version: '1.0.0',
format: 'CLDF',
creationDate: DateTime.now(),
platform: Platform.mobile,
appVersion: '1.0.0',
),
locations: [
Location(
id: 1,
name: 'Test Crag',
country: 'USA',
isIndoor: false,
),
],
routes: [
Route(
id: 1,
locationId: 1,
name: 'Classic Route',
routeType: RouteType.route,
grades: {'french': '6a'},
),
],
climbs: [
Climb(
id: 1,
date: DateTime.now(),
routeName: 'Classic Route',
type: ClimbType.route,
finishType: FinishType.redpoint,
attempts: 2,
),
],
);
final writer = CLDFWriter();
await writer.writeFile('output.cldf', archive);
Working with JSON #
All models support JSON serialization:
// Convert to JSON
final climbJson = climb.toJson();
// Parse from JSON
final climb = Climb.fromJson(jsonData);
Models #
The package provides models for all CLDF entities:
Manifest- Archive metadataLocation- Climbing locationsSector- Sectors within locationsRoute- Routes and bouldersClimb- Individual climb recordsSession- Climbing sessionsTag- Tags for categorization
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
This project is licensed under the MIT License - see the LICENSE file for details.