GeometryGym.Ifc.ParserIfc.GetKeyWord C# (CSharp) Méthode

GetKeyWord() static private méthode

static private GetKeyWord ( string line, int &ifcID, string &keyword, string &def ) : void
line string
ifcID int
keyword string
def string
Résultat void
        internal static void GetKeyWord(string line, out int ifcID, out string keyword, out string def)
        {
            keyword = "";
            def = "";
            ifcID = 0;
            if (string.IsNullOrEmpty(line))
                return;
            string strLine = line.Trim();
            int jlast = strLine.Length, jcounter = (line[0] == '#' ? 1 : 0);
            char c;
            for (; jcounter < jlast; jcounter++)
            {
                c = strLine[jcounter];
                if (char.IsDigit(c))
                    def += c;
                else
                    break;
            }
            if (!string.IsNullOrEmpty(def))
                ifcID = int.Parse(def);
            c = strLine[jcounter];
            while (c == ' ')
                c = strLine[++jcounter];
            if (strLine[jcounter] == '=')
                jcounter++;
            c = strLine[jcounter];
            while (c == ' ')
                c = strLine[++jcounter];
            if (c != 'I')
                return;
            for (; jcounter < jlast; jcounter++)
            {
                c = strLine[jcounter];
                if (c == '(')
                    break;
                keyword += c;
            }
            keyword = keyword.Trim();
            keyword = keyword.ToUpper();
            int len = strLine.Length;
            int ilast = 1;
            while (strLine[len - ilast] != ')')
            {
                ilast++;
                if(len - ilast == jcounter)
                {
                    ilast = 0;
                    break;
                }
            }
            def = strLine.Substring(jcounter + 1, len - jcounter - ilast - 1);//(strLine[len-1] == ';' ? 3 : 2));
        }

Usage Example

Exemple #1
0
        internal static IfcColour parseColour(string str)
        {
            string kw = "", def = "";
            int    id = 0;

            ParserIfc.GetKeyWord(str, out id, out kw, out def);
            if (string.IsNullOrEmpty(kw))
            {
                return(null);
            }
            if (string.Compare(kw, "IFCCOLOURRGB", false) == 0)
            {
                return(IfcColourRgb.Parse(str));
            }
            if (string.Compare(kw, "IFCDRAUGHTINGPREDEFINEDCOLOUR", false) == 0)
            {
                return(IfcDraughtingPreDefinedColour.Parse(str));
            }
            return(null);
        }
All Usage Examples Of GeometryGym.Ifc.ParserIfc::GetKeyWord