Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Parsing Cascading Style Sheet like file
QtWS25 Last Chance

Parsing Cascading Style Sheet like file

Scheduled Pinned Locked Moved General and Desktop
parseparsingcss
4 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ralf
    wrote on 28 Jul 2015, 06:00 last edited by
    #1

    I have a document in a a *.css (Cascading Style Sheets) like format. Actually it is a personalized css (I call it *.pss), with own tags and properties. here I have an excerpt:

    /* CSS like style sheet file *.pss */
    @include "otherStyleSheet.pss";

    /* comment */
    [propertyID="72100000"] {
    fillColor : #f3f1ed;
    minSize : 5;
    lineWidth : 3;
    }

    /* sphere */
    [propertyID="2352????"] {
    lineType : dotted;
    }

    /* square */
    [propertyID="2115????"] {
    lineType : thinline;
    }

    /* ring */
    [propertyID="2315????"] {
    lineType : thickline;
    [hasInnerRing=true] {
    innerLineType : thinline;
    }
    }

    1. I would like to parse it very easily.
    2. My task then is to transform that parsed input to an internal data structure, which shall represent that already parsed file.
    3. When I make changes to that, I would like to overwrite these changes very easily to that file.

    Is there already something Ready-To-Use from Qt? What would be the easiest way?

    Thanx in advance.
    Regards
    Ralf

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 28 Jul 2015, 07:18 last edited by
      #2

      Hi and welcome

      Can I ask if it must be pss ?
      Sine you want to parse it easy, its not the most easy start making a new format.

      As far as I know - there is no Qt easy way of parsing in/write out such custom format.
      Of cause you can build your own parser/serializer but it get complex pretty fast.

      So you could go much easier (IMO) if you used xml or json as
      that loads the data into a structure that you can modify and
      write back to file without much hassle.

      Also you have the classic issue with comments. They are more part of the file than the data itself so to keep them when file
      is rewritten, special care must be taken.

      With xml that supports comments, you get this for "free".

      Of cause It all depends what you really want. if the job IS to write such parser for pss then just forget what i just said :)

      R 1 Reply Last reply 28 Jul 2015, 07:29
      0
      • M mrjj
        28 Jul 2015, 07:18

        Hi and welcome

        Can I ask if it must be pss ?
        Sine you want to parse it easy, its not the most easy start making a new format.

        As far as I know - there is no Qt easy way of parsing in/write out such custom format.
        Of cause you can build your own parser/serializer but it get complex pretty fast.

        So you could go much easier (IMO) if you used xml or json as
        that loads the data into a structure that you can modify and
        write back to file without much hassle.

        Also you have the classic issue with comments. They are more part of the file than the data itself so to keep them when file
        is rewritten, special care must be taken.

        With xml that supports comments, you get this for "free".

        Of cause It all depends what you really want. if the job IS to write such parser for pss then just forget what i just said :)

        R Offline
        R Offline
        Ralf
        wrote on 28 Jul 2015, 07:29 last edited by Ralf
        #3

        @mrjj Unfortunately the format is fixed and not choosen by myself. So XML and JSON is ruled out :(
        Then I start to write my own serializer.
        Thnx for the answer.

        M 1 Reply Last reply 28 Jul 2015, 07:45
        0
        • R Ralf
          28 Jul 2015, 07:29

          @mrjj Unfortunately the format is fixed and not choosen by myself. So XML and JSON is ruled out :(
          Then I start to write my own serializer.
          Thnx for the answer.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Jul 2015, 07:45 last edited by
          #4

          @Ralf
          Oh, :(
          Well in that case I would download source code for whole Qt
          and have a look of what they use for
          the qss (css) parsing and see if some could be reused. ( i have no idea)

          Also
          http://www.codeproject.com/Articles/20450/Simple-CSS-Parser

          is a good read (IMO) for toughs about writing such parser.

          Good luck

          1 Reply Last reply
          2

          2/4

          28 Jul 2015, 07:18

          • Login

          • Login or register to search.
          2 out of 4
          • First post
            2/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved