Example #1
0
        protected void ReadRegularProperty(string curLine)
        {
            Match  m   = PBXRegex.KeyValue.Match(curLine.Trim());
            string key = m.Groups[1].Value.Trim();

            m_Properties[key] = PBXStream.UnquoteString(m.Groups[2].Value.Trim());
        }
Example #2
0
        protected override void ReadFromSectionImpl(string curLine, TextReader sr)
        {
            Match m = PBXRegex.AnyKeyValue.Match(curLine.Trim());

            text = m.Groups[2].Value;

            m    = PBXRegex.FileRef.Match(curLine);
            name = path = PBXStream.UnquoteString(m.Groups[2].Value.Trim());
            if (PBXRegex.FileRefName.IsMatch(curLine))
            {
                name = PBXStream.UnquoteString(PBXRegex.FileRefName.Match(curLine).Groups[1].Value);
            }
        }
Example #3
0
        public void Read(string curLine, TextReader sr)
        {
            val.Clear();

            if (PBXRegex.ListHeader.IsMatch(curLine))
            {
                Match m = PBXRegex.ListHeader.Match(curLine);
                name = PBXStream.UnquoteString(m.Groups[1].Value);
                PBXStream.ReadLinesUntilConditionIsMet(sr, val, ExtractValue, s => s.Trim() == ");");
            }
            else
            {
                Match m = PBXRegex.KeyValue.Match(curLine);
                name = PBXStream.UnquoteString(m.Groups[1].Value);
                AddValue(PBXStream.UnquoteString(m.Groups[2].Value));
            }
        }
Example #4
0
        public static PBXFileReference CreateFromFile(string path, string projectFileName,
                                                      PBXSourceTree tree)
        {
            string guid = PBXGUID.Generate();

            var fileRef = new PBXFileReference();

            fileRef.guid = guid;

            fileRef.path = path;
            fileRef.name = projectFileName;
            fileRef.text = String.Format("{{isa = PBXFileReference; lastKnownFileType = {0}; name = {1}; path = {2}; sourceTree = {3}; }}",
                                         FileTypeUtils.GetTypeName(Path.GetExtension(fileRef.name)),
                                         PBXStream.QuoteStringIfNeeded(fileRef.name),
                                         PBXStream.QuoteStringIfNeeded(fileRef.path),
                                         PBXStream.QuoteStringIfNeeded(FileTypeUtils.SourceTreeDesc(tree)));
            return(fileRef);
        }
Example #5
0
 public void Write(TextWriter sw, GUIDToCommentMap comments)
 {
     if (val.Count == 0)
     {
     }
     else if (val.Count == 1)
     {
         sw.WriteLine("\t\t\t\t{0} = {1};", PBXStream.QuoteStringIfNeeded(name), PBXStream.QuoteStringIfNeeded(val[0]));
     }
     else
     {
         sw.WriteLine("\t\t\t\t{0} = (", PBXStream.QuoteStringIfNeeded(name));
         foreach (string s in val)
         {
             sw.WriteLine("\t\t\t\t\t{0},", PBXStream.QuoteStringIfNeeded(s));
         }
         sw.WriteLine("\t\t\t\t);");
     }
 }
Example #6
0
        public void ReadFromStream(TextReader sr)
        {
            PBXStream.ReadLinesWithConditionForLastLine(sr, m_Header, s => s.Trim() == "objects = {");

            string line = PBXStream.ReadSkippingEmptyLines(sr);

            string prevSectionName = null;

            while (PBXRegex.BeginSection.IsMatch(line))
            {
                string sectName = PBXRegex.BeginSection.Match(line).Groups[1].Value;

                // Duplicate sections (which should never appear) will be simply read again.
                if (m_Section.ContainsKey(sectName))
                {
                    m_Section[sectName].ReadSection(line, sr);
                }
                else
                {
                    SectionBase sect = new TextSection();
                    sect.ReadSection(line, sr);
                    m_Section.Add(sectName, sect);
                }

                // if the section is unknown, save its position relative to other sections
                if (!m_SectionOrder.Contains(sectName))
                {
                    int pos = 0;
                    if (prevSectionName != null)                                    // TODO: static analysis: expression is always false
                    {
                        pos  = m_SectionOrder.FindIndex(x => x == prevSectionName); // this never fails
                        pos += 1;
                    }

                    m_SectionOrder.Insert(pos, sectName);
                }
                line = PBXStream.ReadSkippingEmptyLines(sr);
            }

            m_Footer.Add(line);
            PBXStream.ReadLinesFromFile(sr, m_Footer);
        }
Example #7
0
        public override void ReadSection(string curLine, TextReader sr)
        {
            if (!PBXRegex.BeginSection.IsMatch(curLine))
            {
                throw new Exception("Can't read section");
            }
            if (PBXRegex.BeginSection.Match(curLine).Groups[1].Value != m_Name)
            {
                throw new Exception("Wrong section");
            }

            curLine = PBXStream.ReadSkippingEmptyLines(sr);
            while (!PBXRegex.EndSection.IsMatch(curLine))
            {
                var obj = new T();
                obj.ReadFromSection(curLine, sr);
                entry[obj.guid] = obj;

                curLine = sr.ReadLine();
            }
        }
Example #8
0
 public static string ExtractValue(string src)
 {
     return(PBXStream.UnquoteString(src.Trim().TrimEnd(',')));
 }
Example #9
0
 protected void WriteRegularProperty(string prop, TextWriter sw)
 {
     sw.WriteLine("\t\t\t{0} = {1};", prop, PBXStream.QuoteStringIfNeeded(m_Properties[prop]));
 }
Example #10
0
 public override void ReadSection(string curLine, TextReader sr)
 {
     text.Add(curLine);
     PBXStream.ReadLinesWithConditionForLastLine(sr, text, s => PBXRegex.EndSection.IsMatch(s));
 }