melon.yin 2 lat temu
commit
02e4d76397
12 zmienionych plików z 385 dodań i 0 usunięć
  1. 29 0
      .gitignore
  2. 10 0
      .metadata
  3. 3 0
      CHANGELOG.md
  4. 1 0
      LICENSE
  5. 39 0
      README.md
  6. 4 0
      analysis_options.yaml
  7. 87 0
      lib/vid_extended_data.dart
  8. 14 0
      lib/vid_tag.dart
  9. 16 0
      lib/vid_value.dart
  10. 121 0
      lib/vid_value_element.dart
  11. 58 0
      pubspec.yaml
  12. 3 0
      test/fis_lib_vid_ext_test.dart

+ 29 - 0
.gitignore

@@ -0,0 +1,29 @@
+# Miscellaneous
+*.class
+*.log
+*.pyc
+*.swp
+.DS_Store
+.atom/
+.buildlog/
+.history
+.svn/
+
+# IntelliJ related
+*.iml
+*.ipr
+*.iws
+.idea/
+
+# The .vscode folder contains launch configuration and tasks you configure in
+# VS Code which you may wish to be included in version control, so this line
+# is commented out by default.
+#.vscode/
+
+# Flutter/Dart/Pub related
+# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
+/pubspec.lock
+**/doc/api/
+.dart_tool/
+.packages
+build/

+ 10 - 0
.metadata

@@ -0,0 +1,10 @@
+# This file tracks properties of this Flutter project.
+# Used by Flutter tool to assess capabilities and perform upgrades etc.
+#
+# This file should be version controlled and should not be manually edited.
+
+version:
+  revision: c860cba910319332564e1e9d470a17074c1f2dfd
+  channel: stable
+
+project_type: package

+ 3 - 0
CHANGELOG.md

@@ -0,0 +1,3 @@
+## 0.0.1
+
+* TODO: Describe initial release.

+ 1 - 0
LICENSE

@@ -0,0 +1 @@
+TODO: Add your license here.

+ 39 - 0
README.md

@@ -0,0 +1,39 @@
+<!-- 
+This README describes the package. If you publish this package to pub.dev,
+this README's contents appear on the landing page for your package.
+
+For information about how to write a good package README, see the guide for
+[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). 
+
+For general information about developing packages, see the Dart guide for
+[creating packages](https://dart.dev/guides/libraries/create-library-packages)
+and the Flutter guide for
+[developing packages and plugins](https://flutter.dev/developing-packages). 
+-->
+
+TODO: Put a short description of the package here that helps potential users
+know whether this package might be useful for them.
+
+## Features
+
+TODO: List what your package can do. Maybe include images, gifs, or videos.
+
+## Getting started
+
+TODO: List prerequisites and provide or point to information on how to
+start using the package.
+
+## Usage
+
+TODO: Include short and useful examples for package users. Add longer examples
+to `/example` folder. 
+
+```dart
+const like = 'sample';
+```
+
+## Additional information
+
+TODO: Tell users more about the package: where to find more information, how to 
+contribute to the package, how to file issues, what response they can expect 
+from the package authors, and more.

+ 4 - 0
analysis_options.yaml

@@ -0,0 +1,4 @@
+include: package:flutter_lints/flutter.yaml
+
+# Additional information about this file can be found at
+# https://dart.dev/guides/language/analysis-options

+ 87 - 0
lib/vid_extended_data.dart

@@ -0,0 +1,87 @@
+import 'dart:typed_data';
+
+import 'package:vid/us/vid_us_data_reader.dart';
+import 'package:vid/us/vid_us_image_data.dart';
+
+import 'vid_tag.dart';
+import 'vid_value.dart';
+import 'vid_value_element.dart';
+
+extension VidExtendedDataExt on VidUsImageData {
+  /// 获取结构化扩展数据
+  VidExtendedData? getStructExtendedData() {
+    return VidExtendedData.fromBytes(extendedData);
+  }
+}
+
+/// vid文件扩展数据实体
+class VidExtendedData {
+  /// version tag
+  static VidTag get versionTag => VidTag("Vid", "Version");
+
+  /// version num
+  static VidIntegerValueElement get versionValue => VidIntegerValueElement(1);
+
+  late final Map<VidTag, IVidValue> data;
+
+  VidExtendedData(Map<VidTag, IVidValue> tv) {
+    data = tv;
+    add(versionTag, versionValue);
+  }
+
+  void add(VidTag key, IVidValue value) {
+    data[key] = value;
+  }
+
+  static VidExtendedData? fromBytes(Uint8List bytes) {
+    if (bytes.isEmpty) return null;
+    try {
+      final reader = VidUsDataReader(bytes);
+      final count = reader.readInt();
+      if (count <= 0 || count > bytes.length) return null;
+
+      final Map<VidTag, IVidValue> map = {};
+      for (int cursor = 0; cursor < count; cursor++) {
+        final key = reader.readString();
+        final keys = key.split(',');
+        if (keys.length != 3) {
+          return null;
+        }
+
+        final vidTag = VidTag(keys[0], keys[1]);
+        final valueStr = reader.readString();
+        final valueTypeIndex = int.parse(keys[2]);
+        final valueType = ValueType.values[valueTypeIndex];
+        final vidValue = _convertStr2ValEle(valueType, valueStr);
+        map[vidTag] = vidValue;
+      }
+      return VidExtendedData(map);
+    } catch (e) {}
+    return null;
+  }
+
+  static IVidValue _convertStr2ValEle(ValueType type, String value) {
+    switch (type) {
+      case ValueType.string:
+        return VidStringValueElement(value);
+      case ValueType.double:
+        return VidDoubleValueElement(double.parse(value));
+      case ValueType.float:
+        return VidFloatValueElement(double.parse(value));
+      case ValueType.integer:
+        return VidIntegerValueElement(int.parse(value));
+      case ValueType.long:
+        return VidLongValueElement(int.parse(value));
+      case ValueType.uint:
+        return VidUintValueElement(int.parse(value));
+      case ValueType.ulong:
+        return VidUlongValueElement(int.parse(value));
+      case ValueType.ushort:
+        return VidUshortValueElement(int.parse(value));
+      case ValueType.byte:
+        return VidByteValueElement(int.parse(value));
+      case ValueType.short:
+        return VidShortValueElement(int.parse(value));
+    }
+  }
+}

+ 14 - 0
lib/vid_tag.dart

@@ -0,0 +1,14 @@
+class VidTag {
+  late String _group;
+  late String _element;
+  VidTag(String group, String element) {
+    _group = group;
+    _element = element;
+  }
+
+  /// vid group num
+  String get group => _group;
+
+  /// vid element num
+  String get element => _element;
+}

+ 16 - 0
lib/vid_value.dart

@@ -0,0 +1,16 @@
+abstract class IVidValue {
+  ValueType get type;
+}
+
+enum ValueType {
+  string,
+  integer,
+  double,
+  float,
+  uint,
+  short,
+  ushort,
+  long,
+  ulong,
+  byte,
+}

+ 121 - 0
lib/vid_value_element.dart

@@ -0,0 +1,121 @@
+import 'package:flutter/foundation.dart';
+
+import 'vid_value.dart';
+
+/// <summary>
+/// abstract vid element
+
+/// <typeparam name="T"></typeparam>
+abstract class VidValueElement<T> implements IVidValue {
+  late T _value;
+
+  T get value => _value;
+  @protected
+  set value(T val) => _value = val;
+
+  VidValueElement(T value);
+
+  dynamic getValue() {
+    return value;
+  }
+}
+
+/// Integer element for vid
+class VidIntegerValueElement extends VidValueElement<int> {
+  VidIntegerValueElement(int val) : super(val) {
+    value = val;
+  }
+
+  @override
+  ValueType get type => ValueType.integer;
+}
+
+/// String element for vid
+class VidStringValueElement extends VidValueElement<String> {
+  @override
+  ValueType get type => ValueType.string;
+
+  VidStringValueElement(String val) : super(val) {
+    value = val;
+  }
+}
+
+/// double element for vid
+class VidDoubleValueElement extends VidValueElement<double> {
+  @override
+  ValueType get type => ValueType.double;
+
+  VidDoubleValueElement(double val) : super(val) {
+    value = val;
+  }
+}
+
+/// float element for vid
+class VidFloatValueElement extends VidValueElement<double> {
+  @override
+  ValueType get type => ValueType.float;
+
+  VidFloatValueElement(double val) : super(val) {
+    value = val;
+  }
+}
+
+/// Uint element for vid
+class VidUintValueElement extends VidValueElement<int> {
+  @override
+  ValueType get type => ValueType.uint;
+
+  VidUintValueElement(int val) : super(val) {
+    value = val;
+  }
+}
+
+/// short element for vid
+class VidShortValueElement extends VidValueElement<int> {
+  @override
+  ValueType get type => ValueType.short;
+
+  VidShortValueElement(int val) : super(val) {
+    value = val;
+  }
+}
+
+/// ushort element for vid
+class VidUshortValueElement extends VidValueElement<int> {
+  @override
+  ValueType get type => ValueType.ushort;
+
+  VidUshortValueElement(int val) : super(val) {
+    value = val;
+  }
+}
+
+/// long element for vid
+class VidLongValueElement extends VidValueElement<int> {
+  @override
+  ValueType get type => ValueType.long;
+
+  VidLongValueElement(int val) : super(val) {
+    value = val;
+  }
+}
+
+/// ulong element for vid
+class VidUlongValueElement extends VidValueElement<int> {
+  @override
+  ValueType get type => ValueType.ulong;
+
+  VidUlongValueElement(int val) : super(val) {
+    value = val;
+  }
+}
+
+/// byte element for vid
+class VidByteValueElement extends VidValueElement<int> {
+  @override
+  ValueType get type => ValueType.byte;
+
+  VidByteValueElement(int val) : super(val) {
+    value = val;
+  }
+}

+ 58 - 0
pubspec.yaml

@@ -0,0 +1,58 @@
+name: fis_vid_ext
+description: A new Flutter package project.
+version: 0.0.1
+homepage:
+publish_to: none
+
+environment:
+  sdk: ">=2.12.0 <3.0.0"
+  flutter: ">=1.17.0"
+
+dependencies:
+  flutter:
+    sdk: flutter
+  vid:
+    git:
+      url: http://git.ius.plus:88/Project-Wing/flutter_vid.git
+
+dev_dependencies:
+  flutter_test:
+    sdk: flutter
+  flutter_lints: ^1.0.0
+
+# For information on the generic Dart part of this file, see the
+# following page: https://dart.dev/tools/pub/pubspec
+
+# The following section is specific to Flutter.
+flutter:
+
+  # To add assets to your package, add an assets section, like this:
+  # assets:
+  #   - images/a_dot_burr.jpeg
+  #   - images/a_dot_ham.jpeg
+  #
+  # For details regarding assets in packages, see
+  # https://flutter.dev/assets-and-images/#from-packages
+  #
+  # An image asset can refer to one or more resolution-specific "variants", see
+  # https://flutter.dev/assets-and-images/#resolution-aware.
+
+  # To add custom fonts to your package, add a fonts section here,
+  # in this "flutter" section. Each entry in this list should have a
+  # "family" key with the font family name, and a "fonts" key with a
+  # list giving the asset and other descriptors for the font. For
+  # example:
+  # fonts:
+  #   - family: Schyler
+  #     fonts:
+  #       - asset: fonts/Schyler-Regular.ttf
+  #       - asset: fonts/Schyler-Italic.ttf
+  #         style: italic
+  #   - family: Trajan Pro
+  #     fonts:
+  #       - asset: fonts/TrajanPro.ttf
+  #       - asset: fonts/TrajanPro_Bold.ttf
+  #         weight: 700
+  #
+  # For details regarding fonts in packages, see
+  # https://flutter.dev/custom-fonts/#from-packages

+ 3 - 0
test/fis_lib_vid_ext_test.dart

@@ -0,0 +1,3 @@
+import 'package:flutter_test/flutter_test.dart';
+
+void main() {}