Asset.vala 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Invercargill;
  2. using Invercargill.Convert;
  3. using Gee;
  4. namespace Ppub {
  5. public class Asset {
  6. public string name {get; set;}
  7. public string mimetype {get; set;}
  8. public uint64 start_location {get; set;}
  9. public uint64 end_location {get; set;}
  10. public uint64 size {
  11. get {
  12. return end_location - start_location;
  13. }
  14. }
  15. public Vector<string> flags {get; set;}
  16. public Asset.from_string(string line) {
  17. var key_value = line.split(": ");
  18. name = key_value[0];
  19. var data = key_value[1].split(" ");
  20. mimetype = data[0];
  21. start_location = int.parse (data[1]);
  22. end_location = int.parse (data[2]);
  23. flags = ate(data).skip(3).to_vector();
  24. }
  25. public string to_string() {
  26. var str = @"$name: $mimetype $start_location $end_location";
  27. foreach (var flag in flags) {
  28. str += @" $flag";
  29. }
  30. str += "\n";
  31. return str;
  32. }
  33. }
  34. }