Tanoda
PipeFileSyntax.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System;
10
11namespace Leap.Unity {
12
13 public class PipeFileSyntax {
14
16 public string path;
17 public int numChannels = 1;
18 public bool didParseNumChannels { get; private set; }
19 public bool combineChannels = false;
20 public bool didParseCombineChannels { get; private set; }
21
24 }
25
26 public PipeFileSyntax(string pathMaybeWithPipes) {
27 string[] pipeArgs = pathMaybeWithPipes.Split('|');
28 this.path = pipeArgs[0];
29 if (pipeArgs.Length > 1) {
30 this.didParseNumChannels = Int32.TryParse(pipeArgs[1],
31 out this.numChannels);
32 }
33 if (pipeArgs.Length > 2) {
34 this.combineChannels = !string.IsNullOrEmpty(pipeArgs[2]) &&
35 (pipeArgs[2].ToUpper().Equals("T") ? true : false);
36 this.didParseCombineChannels = true;
37 }
38 }
39
40 public static PipeFileSyntax Parse(string pathMaybeWithPipes) {
41 return new PipeFileSyntax(pathMaybeWithPipes);
42 }
43
44 public PipeFileSyntax ChangePath(string newPath) {
45 this.path = newPath;
46 return this;
47 }
48
49 public override string ToString() {
50 var sb = new System.Text.StringBuilder();
51 sb.Append(path);
53 sb.Append("|"); sb.Append(numChannels);
55 sb.Append("|"); sb.Append((combineChannels ? "T" : "F"));
56 }
57 }
58 return sb.ToString();
59 }
60
61 }
62
63}
string path
The file path, cleaned of any pipe syntax.
PipeFileSyntax ChangePath(string newPath)
static PipeFileSyntax Parse(string pathMaybeWithPipes)
override string ToString()
PipeFileSyntax(string pathMaybeWithPipes)