diff --git a/DXFeedFramework.xcodeproj/project.pbxproj b/DXFeedFramework.xcodeproj/project.pbxproj index 34e186e2c..2870e6913 100644 --- a/DXFeedFramework.xcodeproj/project.pbxproj +++ b/DXFeedFramework.xcodeproj/project.pbxproj @@ -231,6 +231,8 @@ 6498E6C42AB20B860093A065 /* ScheduleSessionType+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6498E6C32AB20B860093A065 /* ScheduleSessionType+Ext.swift */; }; 649F48862A615BC90016FDD1 /* CandleSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649F48852A615BC90016FDD1 /* CandleSymbol.swift */; }; 649F48882A615BED0016FDD1 /* CandleType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649F48872A615BED0016FDD1 /* CandleType.swift */; }; + 64A42F3B2B07A7A3001C3ACC /* SymbolParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64A42F3A2B07A7A3001C3ACC /* SymbolParser.swift */; }; + 64A42F3E2B07A807001C3ACC /* NativeSymbolParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64A42F3D2B07A807001C3ACC /* NativeSymbolParser.swift */; }; 64AAF0532A8113E800E8942B /* String+Range.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64AAF0522A8113E800E8942B /* String+Range.swift */; }; 64AAF0552A82499A00E8942B /* ConcurrentDict.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64AAF0542A82499A00E8942B /* ConcurrentDict.swift */; }; 64AAF0572A82A3FC00E8942B /* ICandleSymbolProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64AAF0562A82A3FC00E8942B /* ICandleSymbolProperty.swift */; }; @@ -693,6 +695,8 @@ 6498E6C32AB20B860093A065 /* ScheduleSessionType+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ScheduleSessionType+Ext.swift"; sourceTree = ""; }; 649F48852A615BC90016FDD1 /* CandleSymbol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CandleSymbol.swift; sourceTree = ""; }; 649F48872A615BED0016FDD1 /* CandleType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CandleType.swift; sourceTree = ""; }; + 64A42F3A2B07A7A3001C3ACC /* SymbolParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolParser.swift; sourceTree = ""; }; + 64A42F3D2B07A807001C3ACC /* NativeSymbolParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeSymbolParser.swift; sourceTree = ""; }; 64AAF0522A8113E800E8942B /* String+Range.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Range.swift"; sourceTree = ""; }; 64AAF0542A82499A00E8942B /* ConcurrentDict.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConcurrentDict.swift; sourceTree = ""; }; 64AAF0562A82A3FC00E8942B /* ICandleSymbolProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICandleSymbolProperty.swift; sourceTree = ""; }; @@ -1136,6 +1140,7 @@ 64C772002A975102009868C2 /* Reference+Util.swift */, 6464074E2A9F62D4006FF769 /* Date+Ext.swift */, 648BD5702AC583AC004A3A95 /* TimeFormat.swift */, + 64A42F3A2B07A7A3001C3ACC /* SymbolParser.swift */, ); path = Utils; sourceTree = ""; @@ -1244,6 +1249,14 @@ path = Candles; sourceTree = ""; }; + 64A42F3C2B07A7F4001C3ACC /* QDS */ = { + isa = PBXGroup; + children = ( + 64A42F3D2B07A807001C3ACC /* NativeSymbolParser.swift */, + ); + path = QDS; + sourceTree = ""; + }; 64ACBCDB2A28974900032C53 /* Osub */ = { isa = PBXGroup; children = ( @@ -1468,6 +1481,7 @@ 8088D77A29C5D8AD00F240CB /* Native */ = { isa = PBXGroup; children = ( + 64A42F3C2B07A7F4001C3ACC /* QDS */, 80FC415A29CA2B7100E6B611 /* Endpoint */, 8088D77B29C8D96600F240CB /* ErrorHandling */, 642BE4C52A2E1B550052340A /* Events */, @@ -2169,6 +2183,7 @@ 6486B9732AD045C800D8D5FA /* TheoPrice.swift in Sources */, 64ACBCDF2A2897EA00032C53 /* String+Symbol.swift in Sources */, 64B4363A2AB86D1A0003919E /* DayFilter.swift in Sources */, + 64A42F3B2B07A7A3001C3ACC /* SymbolParser.swift in Sources */, 64ECD6872A9DDFBE00B36935 /* DXInstrumentProfileConnection.swift in Sources */, 6406F2572AD9820700B58C42 /* NativePublisher.swift in Sources */, 6486B9772AD04C5800D8D5FA /* TheoPriceMapper.swift in Sources */, @@ -2258,6 +2273,7 @@ 649F48862A615BC90016FDD1 /* CandleSymbol.swift in Sources */, 646407492A9DF984006FF769 /* InstrumentProfileMapper.swift in Sources */, 64656F6B2A1CFAC2006A0B19 /* BridgeUtil.swift in Sources */, + 64A42F3E2B07A807001C3ACC /* NativeSymbolParser.swift in Sources */, 8088D77329C3A2F400F240CB /* GraalException.swift in Sources */, 64C771FF2A9504ED009868C2 /* SnapshotProcessor.swift in Sources */, 64C771F82A94B88C009868C2 /* TimeAndSaleType.swift in Sources */, diff --git a/DXFeedFramework/Native/QDS/NativeSymbolParser.swift b/DXFeedFramework/Native/QDS/NativeSymbolParser.swift new file mode 100644 index 000000000..114442fd5 --- /dev/null +++ b/DXFeedFramework/Native/QDS/NativeSymbolParser.swift @@ -0,0 +1,22 @@ +// +// NativeSymbolParser.swift +// DXFeedFramework +// +// Created by Aleksey Kosylo on 17.11.23. +// + +import Foundation +@_implementationOnly import graal_api + +class NativeSymbolParser { + func parse(_ symbols: String) throws -> [String] { + let thread = currentThread() + let symbols = try ErrorCheck.nativeCall(thread, dxfg_Tools_parseSymbols(thread, symbols.toCStringRef())) + var result = [String]() + for index in 0.. [String] { + let nativeParser = NativeSymbolParser() + return try nativeParser.parse(symbols) + } +} diff --git a/Samples/Tools/Arguments.swift b/Samples/Tools/Arguments.swift index aaaeaddcd..a6e920f1e 100644 --- a/Samples/Tools/Arguments.swift +++ b/Samples/Tools/Arguments.swift @@ -107,49 +107,10 @@ Cmd \(cmd) contains not enough \(cmd.count - 1) arguments. Expected \(requiredNu if namelessParameters.count <= index { return [WildcardSymbol.all] } - let symbols = namelessParameters[index] if symbols.lowercased() == "all" { return [WildcardSymbol.all] } - - var symbolsList = [String]() - func addSymbol(str: String) { - if str.hasPrefix("ipf[") && str.hasSuffix("]") { - if let address = str.slice(from: "[", to: "]") { - let profiles = try? DXInstrumentProfileReader().readFromFile(address: address) - profiles?.forEach({ profile in - symbolsList.append(profile.symbol) - }) - } - } else { - symbolsList.append(str) - } - } - var parentheses = 0 - var tempSrting = "" - symbols.forEach { character in - switch character { - case "{", "(", "[": - parentheses += 1 - tempSrting.append(character) - case "}", ")", "]": - if parentheses > 0 { - parentheses -= 1 - } - tempSrting.append(character) - case ",": - if parentheses == 0 { - addSymbol(str: tempSrting) - tempSrting = "" - } else { - tempSrting.append(character) - } - default: - tempSrting.append(character) - } - } - addSymbol(str: tempSrting) - return symbolsList + return (try? SymbolParser.parse(symbols)) ?? [String]() } }