private void VerifyListSplitterElementPipeline( PipelineOptions options, SplitOption splitOn) { // Pass the configuration to the builder to create the pipeline. var pipeline = _builder.BuildFromConfiguration(options); var element = pipeline.GetElement <ListSplitterElement>(); // Check we've got the expected number of evidence keys. Assert.AreEqual(1, element.EvidenceKeys.Count); // Create, populate and process flow data. var flowData = pipeline.CreateFlowData(); flowData.AddEvidence(element.EvidenceKeys[0], "123,45\"6|789,0") .Process(); // Get the result and verify it. var elementData = flowData.GetFromElement(element); switch (splitOn) { case SplitOption.Comma: Assert.AreEqual("123", elementData.Result[0]); Assert.AreEqual("45\"6|789", elementData.Result[1]); Assert.AreEqual("0", elementData.Result[2]); break; case SplitOption.Pipe: Assert.AreEqual("123,45\"6", elementData.Result[0]); Assert.AreEqual("789,0", elementData.Result[1]); break; case SplitOption.CommaMaxLengthThree: Assert.AreEqual("123", elementData.Result[0]); Assert.AreEqual("45\"", elementData.Result[1]); Assert.AreEqual("6|7", elementData.Result[2]); Assert.AreEqual("89", elementData.Result[3]); Assert.AreEqual("0", elementData.Result[4]); break; case SplitOption.CommaAndPipe: Assert.AreEqual("123", elementData.Result[0]); Assert.AreEqual("45\"6", elementData.Result[1]); Assert.AreEqual("789", elementData.Result[2]); Assert.AreEqual("0", elementData.Result[3]); break; case SplitOption.PipeAndQuote: Assert.AreEqual("123,45", elementData.Result[0]); Assert.AreEqual("6", elementData.Result[1]); Assert.AreEqual("789,0", elementData.Result[2]); break; default: break; } }
/// <summary> /// Split the interval into two intervals at the given point, or nearest valid point. /// </summary> /// <param name = "atPoint">The point where to split.</param> /// <param name = "option">Option which specifies in which intervals the split point ends up.</param> /// <param name = "before">The interval in which to store the part before the point, if any, null otherwise.</param> /// <param name = "after">The interval in which to store the part after the point, if any, null otherwise.</param> public void Split(T atPoint, SplitOption option, out Interval <T> before, out Interval <T> after) { Interval <T, T> beforeInner; Interval <T, T> afterInner; Split(atPoint, option, out beforeInner, out afterInner); before = new Interval <T>(beforeInner); after = new Interval <T>(afterInner); }
/// <summary> /// Split the interval into two intervals at the given date, or nearest valid point. /// </summary> /// <param name = "atPoint">The point in time where to split.</param> /// <param name = "option">Option which specifies in which intervals the split point ends up.</param> /// <param name = "before">The interval in which to store the part before the specified date, if any, null otherwise.</param> /// <param name = "after">The interval in which to store the part after the specified date, if any, null otherwise.</param> public void Split(DateTime atPoint, SplitOption option, out TimeInterval before, out TimeInterval after) { Interval <DateTime, TimeSpan> beforeInner; Interval <DateTime, TimeSpan> afterInner; Split(atPoint, option, out beforeInner, out afterInner); before = new TimeInterval(beforeInner); after = new TimeInterval(afterInner); }
public static string[] Split(string s, char cSeparator, bool bSupDebFin) { SplitOption splitOption = SplitOption.None; if (bSupDebFin) { splitOption = SplitOption.Trim; } return(_Split(s, new char[] { cSeparator }, null, splitOption)); }
/// <summary> /// Split a string into two strings at a specified position. /// </summary> /// <param name = "source">The source for this extension method.</param> /// <param name = "index">The index where to split the string.</param> /// <param name = "splitOption">Option specifying whether to include the character where is split in the resulting strings.</param> /// <returns>A string array containing both strings after the split.</returns> public static string[] SplitAt(this string source, int index, SplitOption splitOption = SplitOption.None) { Contract.Requires(index >= 0 && index < source.Length); return(new[] { source.Substring(0, index + (splitOption.EqualsAny(SplitOption.Left, SplitOption.Both) ? 1 : 0)), source.Substring(index + (splitOption.EqualsAny(SplitOption.Right, SplitOption.Both) ? 0 : 1)) }); }
/// <summary> /// Split a string into two strings at a specified position. /// </summary> /// <param name = "source">The source for this extension method.</param> /// <param name = "index">The index where to split the string.</param> /// <param name = "splitOption">Option specifying whether to include the character where is split in the resulting strings.</param> /// <returns>A string array containing both strings after the split.</returns> public static string[] SplitAt( this string source, int index, SplitOption splitOption = SplitOption.None ) { Contract.Requires( index >= 0 && index < source.Length ); return new[] { source.Substring( 0, index + (splitOption.EqualsAny( SplitOption.Left, SplitOption.Both ) ? 1 : 0) ), source.Substring( index + (splitOption.EqualsAny( SplitOption.Right, SplitOption.Both ) ? 0 : 1) ) }; }
public static string[] Split(string s, char[] cSeparator, char[,] cCharZone, bool bSupDebFin) { SplitOption splitOption = SplitOption.None; if (bSupDebFin) { splitOption = SplitOption.Trim; } return(_Split(s, cSeparator, cCharZone, splitOption)); }
private static string[][] _testSplitExtension(SplitOption following_option, SplitOption trailing_option, bool keep_empty_entries, SplitGreed greed = SplitGreed.Trailing) { string[][] dont_optimize_me = null; foreach (string test_string in TestArray.SplitStringArray) { dont_optimize_me = test_string.SplitExtensionTrack(following_option, trailing_option, keep_empty_entries, greed, TestArray.SplitSeparators); } return(dont_optimize_me); }
static void SplitTestHelper <T, TSize>( T start, TSize addition, T atPoint, SplitOption splitOption, Interval <T, TSize> expectedBefore, Interval <T, TSize> expectedAfter) where T : IComparable <T> where TSize : IComparable <TSize> { Interval <T, TSize> interval = NewInterval(start, addition); interval.Split(atPoint, splitOption, out IInterval <T, TSize> before, out IInterval <T, TSize> after); Assert.Equal(expectedBefore, before); Assert.Equal(expectedAfter, after); }
/// <summary> /// Split a string into two strings at a specified position. /// </summary> /// <param name = "source">The source for this extension method.</param> /// <param name = "index">The index where to split the string.</param> /// <param name = "splitOption">Option specifying whether to include the character where is split in the resulting strings.</param> /// <returns>A string array containing both strings after the split.</returns> public static string[] SplitAt(this string source, int index, SplitOption splitOption = SplitOption.None) { if (index < 0 || index >= source.Length) { throw new ArgumentException("Specified split index is outside of the range of the string.", nameof(index)); } return(new[] { source.Substring(0, index + (splitOption.EqualsAny(SplitOption.Left, SplitOption.Both) ? 1 : 0)), source.Substring(index + (splitOption.EqualsAny(SplitOption.Right, SplitOption.Both) ? 0 : 1)) }); }
/* * 截取字符串(字符) */ public static string[] MySplit(this string text, char cSplite, SplitOption option = SplitOption.ALL) { if (string.IsNullOrEmpty(text)) { return(null); } string[] resultString = text.Split(cSplite); if (option == SplitOption.NOTNULL) // 删除空白字符串 { resultString = resultString.Where(s => !string.IsNullOrEmpty(s)).ToArray(); } return(resultString); }
public static string[] Split(string s, char cSeparator, char[,] cCharZone, bool bSupDebFin, bool bSupDoubleQuot) { SplitOption splitOption = SplitOption.None; if (bSupDebFin) { splitOption = SplitOption.Trim; } if (bSupDoubleQuot) { splitOption |= SplitOption.RemoveDoubleQuot; } return(_Split(s, new char[] { cSeparator }, cCharZone, splitOption)); }
public static string[] Split(string s, char[] cSeparator, bool bSupDebFin, bool bSupDoubleQuot) { SplitOption splitOption = SplitOption.None; if (bSupDebFin) { splitOption = SplitOption.Trim; } if (bSupDoubleQuot) { splitOption |= SplitOption.RemoveDoubleQuot; } return(_Split(s, cSeparator, null, splitOption)); }
public static string[] Split(string s, SplitOption splitOption) { List<char> cSeparator = new List<char>(); if ((splitOption & SplitOption.SplitLine) == SplitOption.SplitLine) { cSeparator.Add('\r'); cSeparator.Add('\n'); } if ((splitOption & SplitOption.SplitSpace) == SplitOption.SplitSpace) cSeparator.Add(' '); if ((splitOption & SplitOption.SplitTab) == SplitOption.SplitTab) cSeparator.Add('\t'); return _Split(s, cSeparator.ToArray(), null, splitOption); }
public static string[] Split(string s, char[] cSeparator, char[,] cCharZone, bool bSupDebFin, bool bSupDoubleQuot, bool bSupElementVide) { SplitOption splitOption = SplitOption.None; if (bSupDebFin) { splitOption = SplitOption.Trim; } if (bSupDoubleQuot) { splitOption |= SplitOption.RemoveDoubleQuot; } if (bSupElementVide) { splitOption |= SplitOption.RemoveEmptyString; } return(_Split(s, cSeparator, cCharZone, splitOption)); }
/* * 截取字符串(字符串) * 0 成功 1 字符串问题 2 截取字段问题 */ public static string[] MySplit(this string text, string strSplit, SplitOption option = SplitOption.ALL) { if (string.IsNullOrEmpty(text)) { return(null); } if (string.IsNullOrEmpty(strSplit)) { return(null); } string[] resultString = Regex.Split(text, strSplit, RegexOptions.IgnoreCase); if (option == SplitOption.NOTNULL)// 删除空白字符串 { resultString = resultString.Where(s => !string.IsNullOrEmpty(s)).ToArray(); } return(resultString); }
public static string[] Split(string s, SplitOption splitOption) { List <char> cSeparator = new List <char>(); if ((splitOption & SplitOption.SplitLine) == SplitOption.SplitLine) { cSeparator.Add('\r'); cSeparator.Add('\n'); } if ((splitOption & SplitOption.SplitSpace) == SplitOption.SplitSpace) { cSeparator.Add(' '); } if ((splitOption & SplitOption.SplitTab) == SplitOption.SplitTab) { cSeparator.Add('\t'); } return(_Split(s, cSeparator.ToArray(), null, splitOption)); }
public GStringList Split(GString f, SplitOption splitop, CaseOption caseop) { GStringList vect = new GStringList(); if (this.Find(f, caseop) == -1) { vect.PushBack(this); return(vect); } int pos = 0, pos1 = 0, pos2 = 0; while (true) { pos1 = pos; pos = this.Find(f, pos, caseop); if (pos == -1) { break; } pos2 = pos; GString ne = this.Substr(pos1, pos2); if ((splitop == GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS) { vect.PushBack(ne); } pos += f.Size; } if (pos1 != 0) { GString ne = new GString(this.Substr(pos1, this.Size)); if ((splitop == G.GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS) { vect.PushBack(ne); } } return(vect); }
public GStringList Explode(GString f, SplitOption splitop, CaseOption caseop) { return(this.Split(f, splitop, caseop)); }
public GStringList Explode(GString f, SplitOption splitop, CaseOption caseop) { return (this.Split(f, splitop, caseop)); }
public GStringList Split(GString f, SplitOption splitop , CaseOption caseop) { GStringList vect = new GStringList(); if (this.Find(f, caseop) == -1) { vect.PushBack(this); return (vect); } int pos = 0, pos1 = 0, pos2 = 0; while (true) { pos1 = pos; pos = this.Find(f, pos, caseop); if (pos == -1) break; pos2 = pos; GString ne = this.Substr(pos1, pos2); if ((splitop == GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS) vect.PushBack(ne); pos += f.Size; } if (pos1 != 0) { GString ne = new GString (this.Substr(pos1, this.Size)); if ((splitop == G.GString.SplitOption.SKIP_EMPTY_PARTS && ne.Size != 0) || splitop == G.GString.SplitOption.KEEP_EMPTY_PARTS) vect.PushBack(ne); } return (vect); }
private static string[] _Split(string s, char[] cSeparator, char[,] cCharZone, SplitOption splitOption) { char c; int i, ic, iDebutElement; string[] r; List <string> alSplit; StringZones sz; if (s == null) { return(new string[0]); } if (cCharZone == null) { r = s.Split(cSeparator); } else { // cCharZone tableau des caractères de délimitation des zones par exemple ( et ) // le tableau doit avoir comme dimension [n,2] // split en tenant compte des zones de texte délimitées par cCharZone alSplit = new List <string>(); sz = new StringZones(s, cCharZone); iDebutElement = 0; while ((ic = sz.ReadChar()) != -1) { c = (char)ic; if (Array.IndexOf(cSeparator, c) != -1) { alSplit.Add(s.Substring(iDebutElement, sz.IndexNextChar - 1 - iDebutElement)); iDebutElement = sz.IndexNextChar; } } //if (sz.IndiceNextChar - 1 - iDebutElement > 0) if (sz.IndexNextChar - iDebutElement > 0) { alSplit.Add(s.Substring(iDebutElement, sz.IndexNextChar - iDebutElement)); } else { alSplit.Add(""); } r = new string[alSplit.Count]; alSplit.CopyTo(r); } //if (bTrim) // for(i = 0; i < r.Length; i++) r[i] = r[i].Trim(); //if (bRemoveDoubleQuot) // for(i = 0; i < r.Length; i++) // { // s = r[i]; // if (s.StartsWith("\"") && s.EndsWith("\"")) // r[i] = s.Substring(1, s.Length - 2); // } if ((splitOption & SplitOption.RemoveDoubleQuot) == SplitOption.RemoveDoubleQuot || (splitOption & SplitOption.TrimStart) == SplitOption.TrimStart || (splitOption & SplitOption.TrimEnd) == SplitOption.TrimEnd) { for (i = 0; i < r.Length; i++) { s = r[i]; bool bNew = false; if ((splitOption & SplitOption.RemoveDoubleQuot) == SplitOption.RemoveDoubleQuot) { if (s.StartsWith("\"") && s.EndsWith("\"")) { s = s.Substring(1, s.Length - 2); bNew = true; } } if ((splitOption & SplitOption.Trim) == SplitOption.Trim) { s = s.Trim(); bNew = true; } else if ((splitOption & SplitOption.TrimStart) == SplitOption.TrimStart) { s = s.TrimStart(); bNew = true; } else if ((splitOption & SplitOption.TrimEnd) == SplitOption.TrimEnd) { s = s.TrimEnd(); bNew = true; } if (bNew) { r[i] = s; } } } //if (bRemoveEmpty) if ((splitOption & SplitOption.RemoveEmptyString) == SplitOption.RemoveEmptyString) { alSplit = new List <string>(); for (i = 0; i < r.Length; i++) { if (r[i] != "") { alSplit.Add(r[i]); } } r = new string[alSplit.Count]; alSplit.CopyTo(r); } return(r); }
private static string[] _Split(string s, char[] cSeparator, char[,] cCharZone, SplitOption splitOption) { char c; int i, ic, iDebutElement; string[] r; List<string> alSplit; StringZones sz; if (s == null) return new string[0]; if (cCharZone == null) r = s.Split(cSeparator); else { // cCharZone tableau des caractères de délimitation des zones par exemple ( et ) // le tableau doit avoir comme dimension [n,2] // split en tenant compte des zones de texte délimitées par cCharZone alSplit = new List<string>(); sz = new StringZones(s, cCharZone); iDebutElement = 0; while ((ic = sz.ReadChar()) != -1) { c = (char)ic; if (Array.IndexOf(cSeparator, c) != -1) { alSplit.Add(s.Substring(iDebutElement, sz.IndexNextChar - 1 - iDebutElement)); iDebutElement = sz.IndexNextChar; } } //if (sz.IndiceNextChar - 1 - iDebutElement > 0) if (sz.IndexNextChar - iDebutElement > 0) alSplit.Add(s.Substring(iDebutElement, sz.IndexNextChar - iDebutElement)); else alSplit.Add(""); r = new string[alSplit.Count]; alSplit.CopyTo(r); } //if (bTrim) // for(i = 0; i < r.Length; i++) r[i] = r[i].Trim(); //if (bRemoveDoubleQuot) // for(i = 0; i < r.Length; i++) // { // s = r[i]; // if (s.StartsWith("\"") && s.EndsWith("\"")) // r[i] = s.Substring(1, s.Length - 2); // } if ((splitOption & SplitOption.RemoveDoubleQuot) == SplitOption.RemoveDoubleQuot || (splitOption & SplitOption.TrimStart) == SplitOption.TrimStart || (splitOption & SplitOption.TrimEnd) == SplitOption.TrimEnd) { for (i = 0; i < r.Length; i++) { s = r[i]; bool bNew = false; if ((splitOption & SplitOption.RemoveDoubleQuot) == SplitOption.RemoveDoubleQuot) { if (s.StartsWith("\"") && s.EndsWith("\"")) { s = s.Substring(1, s.Length - 2); bNew = true; } } if ((splitOption & SplitOption.Trim) == SplitOption.Trim) { s = s.Trim(); bNew = true; } else if ((splitOption & SplitOption.TrimStart) == SplitOption.TrimStart) { s = s.TrimStart(); bNew = true; } else if ((splitOption & SplitOption.TrimEnd) == SplitOption.TrimEnd) { s = s.TrimEnd(); bNew = true; } if (bNew) r[i] = s; } } //if (bRemoveEmpty) if ((splitOption & SplitOption.RemoveEmptyString) == SplitOption.RemoveEmptyString) { alSplit = new List<string>(); for (i = 0; i < r.Length; i++) if (r[i] != "") alSplit.Add(r[i]); r = new string[alSplit.Count]; alSplit.CopyTo(r); } return r; }
/// <summary> /// Split the interval into two intervals at the given point, or nearest valid point. /// </summary> /// <param name = "atPoint">The point where to split.</param> /// <param name = "option">Option which specifies in which intervals the split point ends up.</param> /// <param name = "before">The interval in which to store the part before the point, if any, null otherwise.</param> /// <param name = "after">The interval in which to store the part after the point, if any, null otherwise.</param> public void Split(T atPoint, SplitOption option, out IInterval <T> before, out IInterval <T> after) { Split(atPoint, option, out IInterval <T, T> beforeInner, out IInterval <T, T> afterInner); before = ReduceGenerics(beforeInner); after = ReduceGenerics(afterInner); }
public void Run(CancellationToken token) { var log = new Logger.Logger(); // TimeList var plotTimeList = GeneratePlotTimeEnumerable(PlotTimeRequest, TimeString).ToList(); // Configのデフォルトも見る var transistors = this.Bind(Config.Config.Instance.ArgoDefault.Transistors); if (string.IsNullOrEmpty(NetList) && string.IsNullOrEmpty(Config.Config.Instance.ArgoDefault.NetList)) { throw new AriesException("NetListを空にできません.一番目の引数もしくはコンフィグファイルのArgoDefault.NetListで指定してください"); } // 引数で与えたNetListが優先 NetList = FilePath.FilePath.Expand( string.IsNullOrEmpty(NetList) ? Config.Config.Instance.ArgoDefault.NetList : NetList); var guid = Guid.NewGuid(); // タスクファイルを保存してるディレクトリへのパスを展開 var baseDir = Path.Combine(Config.Config.Instance.WorkingRoot, "aries", "task"); if (!Directory.Exists(baseDir)) { Directory.CreateDirectory(baseDir); } if (!File.Exists(NetList)) { throw new AriesException($"Netlistファイルが見つかりません: {NetList}"); } HspicePath = string.IsNullOrEmpty(HspicePath) ? Environment.GetEnvironmentVariable(Argo.Argo.EnvArgoHspice) : HspicePath; if (string.IsNullOrEmpty(HspicePath) || !File.Exists(HspicePath)) { throw new ArgoException($"Hspice can not found: {HspicePath}"); } try { var totalSweep = TotalSweeps.ParseLongWithSiPrefix(); var seed = Seed.ParseLongWithSiPrefix(); var start = SweepStart.ParseLongWithSiPrefix(); var include = new[] { Includes, Config.Config.Instance.ArgoDefault.Includes, Environment.GetEnvironmentVariable(Argo.Argo.EnvArgoIncludes) ?.Split(',', StringSplitOptions.RemoveEmptyEntries) }; var baseRequest = new ArgoRequest { GroupId = guid, Gnd = Gnd.ParseDecimalWithSiPrefix(), // Includesは引数、コンフィグ、環境変数のうち最初にNullじゃないやつを選ぶ。全部Nullなら空のリスト Includes = include.Any(s => s.Any()) ? include.First(s => s.Any()).ToList() : new List <string>(), Seed = seed, // Signalsは引数がNullならコンフィグを選ぶ Signals = (Signals ?? Config.Config.Instance.ArgoDefault.Signals).ToList(), Sweep = totalSweep, Temperature = Temperature.ParseDecimalWithSiPrefix(), Time = new RangeParameter(TimeString), Transistors = transistors, Vdd = Vdd.ParseDecimalWithSiPrefix(), HspiceOptions = Options.ToList(), HspicePath = HspicePath, IcCommands = IcCommands.ToList(), NetList = NetList, SweepStart = start, PlotTimeList = plotTimeList }; //var dbName = baseRequest.GetHashString(); //baseRequest.ResultFile = dbName; if (SplitOption == "none") { WriteTaskFile(Path.Combine(baseDir, $"{guid}.json"), baseRequest); } else { var(by, size) = SplitOption.Split(':', StringSplitOptions.RemoveEmptyEntries) switch { var s when s.Length != 2 => throw new AriesException( "SplitOptionに与えた引数がフォーマットに従っていません.[seed, sweep]:[size]"), var s when s[1] == "0" => throw new AriesException("[size]に0を指定できません"),