Ejemplo n.º 1
0
        bool doScan(ParseStream oStream)
        {
            if (oStream.empty() || oStream.getData()[0] != '#')
                return false;

            oStream.consume(1);

            // read the characters, it is ok if they are empty
            int n = scanIFragmentChars(oStream.getData());
            oStream.consume(n);

            return true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the input stream into the obj
        /// </summary>
        /// <param name="oStream">The input stream to scan from</param>
        /// <returns>True if part of the Stream was consumed into the obj</returns>
        bool doScan(ParseStream oStream)
        {
            // NOTE: A RelativePath can be empty
            if (oStream.empty())
            {
                return true;
            }

            // doesn't matter if this works or not, will consume what it needs to
            scanXRISegments(oStream);

            return true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses the input stream into XRISegmentVals
        /// </summary>
        /// <param name="oPathStream">The input stream to scan from</param>
        protected void scanXRISegments(ParseStream oPathStream)
        {
            // sets whether colons are allowed
            bool bAllowColon = mbAllowColon;

            // loop through the XRI segments as long as we are consuming something
            bool bConsumed = true;
            while (!oPathStream.empty() && bConsumed)
            {
                bConsumed = false;
                ParseStream oStream = oPathStream.begin();
                bool bStartsWithSlash = (oStream.getData()[0] == '/');

                // if this is the first segment, it must not start with slash
                if ((bStartsWithSlash) && (moSegments.Count == 0))
                {
                    break;
                }

                // if this is not the first segment, we expect a slash
                if ((!bStartsWithSlash) && (moSegments.Count > 0))
                {
                    break;
                }

                // consume the slash if necessary
                if (bStartsWithSlash)
                {
                    bConsumed = true;
                    oStream.consume(1);
                }

                // if there is actually a segment, add it to the list
                XRISegment oSegment = new XRISegment(true, bAllowColon, true);
                if (oSegment.scan(oStream))
                {
                    bConsumed = true;
                    moSegments.Add(oSegment);
                }

                // consume whatever we used (even if the segment was empty)
                oPathStream.end(oStream);

                // after the first segment, colons are allowed
                bAllowColon = true;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses the input stream into the obj
        /// </summary>
        /// <param name="oStream">The input stream to scan from</param>
        /// <returns>True if part of the Stream was consumed into the obj</returns>
        bool doScan(ParseStream oStream)
        {
            // make sure we start with a slash
            if (oStream.empty() || (oStream.getData()[0] != '/'))
            {
                return false;
            }

            // consume the slash
            oStream.consume(1);

            // now scan the XRI segments as we are supposed to
            base.scanXRISegments(oStream);

            // return true no matter what, we got the slash
            return true;
        }
Ejemplo n.º 5
0
        bool doScan(ParseStream oStream)
        {
            if (oStream.empty())
            {
                return false;
            }

            if (oStream.getData()[0] != '(')
            {
                return false;
            }

            ParseStream oTempStream = oStream.begin();
            oTempStream.consume(1);

            String sIRI = null;
            // make sure we have a valid XRI reference
            XRIReference oRef = scanXRIReference(oTempStream);
            if (oRef == null || oTempStream.empty() || (oTempStream.getData()[0] != ')'))
            {
                // if we got a reference, but the resulting temp stream is empty or does not begin with ')'
                // it got parsed wrongly (happens if the XRef is an IRI). Retry parsing with an IRI
                if (oRef != null)
                {
                    oTempStream = oStream.begin();
                    oTempStream.consume(1);
                }
                // if there is no XRI Reference, see if it is an IRI
                sIRI = scanIRI(oTempStream);
                if (sIRI == null)
                {
                    return false;
                }
            }

            // make sure we have the trailing ')'
            if (oTempStream.empty() || (oTempStream.getData()[0] != ')'))
            {
                return false;
            }

            // at this point, complete consumption and return true
            oTempStream.consume(1);
            oStream.end(oTempStream);
            moXRIRef = oRef;
            msIRI = sIRI;

            return true;
        }
Ejemplo n.º 6
0
        bool doScan(ParseStream oStream)
        {
            if (oStream.empty())
            {
                return false;
            }

            ParseStream oTempStream = oStream.begin();

            // make sure we have a valid XRI Value
            XRef oXRef = new XRef();
            if (!oXRef.scan(oTempStream))
            {
                return false;
            }

            // at this point, we know we have enough for a valid xref
            oStream.end(oTempStream);
            moXRoot = oXRef;

            // the cross-reference MAY be followed by an XRI Segment
            // where the star cannot be assumed
            XRISegment oSegment = new XRISegment(false, true, true);
            if (oSegment.scan(oStream))
            {
                moSegment = oSegment;
            }

            return true;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Parses the input stream into the GCS Character String
        /// </summary>
        /// <param name="oParseStream">The input stream to scan from</param>
        /// <returns>True if part of the Stream was consumed</returns>
        private bool scanGCSChar(ParseStream oParseStream)
        {
            if (oParseStream.empty())
            {
                return false;
            }

            switch (oParseStream.getData()[0])
            {
                case '+':
                case '=':
                case '@':
                case '$':
                case '!':
                    {
                        // this way provides a clean copy, whereas substring does not
                        msGCSRoot = char.ToString(oParseStream.getData()[0]);
                        oParseStream.consume(1);
                        return true;
                    }
            }

            return false;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Parses the input stream into the obj
        /// </summary>
        /// <param name="oXRISegStream">The input stream to scan from</param>
        /// <returns>True if part of the Stream was consumed into the obj</returns>
        bool doScan(ParseStream oXRISegStream)
        {
            moSubSegments = new List<XRISubSegment>();
            bool bAllowImpliedDelimiter = mbAllowImpliedDelimiter;
            bool bAllowReassignable = mbAllowReassignable;

            // loop through the stream, but don't consume the real string unless
            // we are successful
            while (!oXRISegStream.empty())
            {
                // determine if we have a delimiter for the next subsegment
                char c = oXRISegStream.getData()[0];

                // break out if the first character has to be persistent and isn't
                if ((!bAllowReassignable) && (c != XRI.PDELIM))
                {
                    break;
                }

                // check if we have a valid non-null subsegment
                XRISubSegment oSubSegment = new XRISubSegment(bAllowImpliedDelimiter, mbAllowColon);
                if (oSubSegment.scan(oXRISegStream))
                {
                    // if we had a valid sub-segment, consume it and add it to the list
                    moSubSegments.Add(oSubSegment);
                }
                else
                {
                    break;
                }

                bAllowImpliedDelimiter = false;
                bAllowReassignable = true;
            }

            // if we have subsegments, we are good.  Otherwise, it is an error
            if (moSubSegments.Count > 0)
            {
                return true;
            }

            moSubSegments = null;
            return false;
        }