示例#1
0
        /// <summary>
        /// Parse a string for a length value.
        /// Expression can include complex expressions
        /// Simplest version of Length parsing
        /// </summary>
        /// <param name="expression">
        ///  [In] The string to parse
        /// </param>
        /// <param name="parse_settings_in">
        ///  [In] Determines what input will be parsed
        /// </param>
        /// <param name="output_unit_system">
        ///  [In] Output value is in this unit system
        /// </param>
        /// <param name="value_out">
        ///  [Out] The length value result
        /// </param>
        /// <returns>
        /// Count of characters parsed or 0 for failure
        /// </returns>
        /// <since>6.0</since>
        public static int ParseLengthExpession(
            string expression,
            StringParserSettings parse_settings_in,
            UnitSystem output_unit_system,
            out double value_out)
        {
            if (null == expression)
            {
                throw new ArgumentNullException();
            }

            IntPtr     settings_in_ptr    = parse_settings_in.ConstPointer();
            UnitSystem parsed_unit_system = UnitSystem.None;

            value_out = RhinoMath.UnsetValue;

            int rc = UnsafeNativeMethods.ON_Parse_LengthExpression(
                expression,
                0,
                -1,
                settings_in_ptr,
                output_unit_system,
                ref value_out,
                IntPtr.Zero,
                ref parsed_unit_system);

            return(rc);
        }
示例#2
0
        /// <summary>
        /// Parse a string for a length value.
        /// Expression can include complex expressions
        /// Most complex version of length parsing
        /// </summary>
        /// <param name="expression">
        ///  [In] The string to parse   </param>
        /// <param name="start_offset">
        ///  [In] Offset position in string to start parsing  </param>
        /// <param name="expression_length">
        ///  [In] Maximum length of string to parse.
        ///  -1 means parse to a terminating character or end of string
        /// </param>
        /// <param name="parse_settings_in">
        ///  [In] Determines what input will be parsed </param>
        ///  If trig functions are included in the expression,
        ///  the angle unit system must be set correctly
        /// <param name="output_unit_system">
        ///  [In] Output value is returned in this unit system </param>
        /// <param name="value_out">
        ///  [Out] The length value result </param>
        /// <param name="parse_results">
        ///  [Out] Describes the results of the parse operation </param>
        /// <param name="parsed_unit_system">
        ///  [Out] If a unit system name was found in the string, it is returned here.
        ///  The output value is in the unit system specified in output_unit_system
        /// </param>
        /// <returns>
        ///  Returns the count of characters that were parsed or 0 if the operation was unsuccessful
        /// </returns>
        /// <since>6.0</since>
        public static int ParseLengthExpession(
            string expression,
            int start_offset,
            int expression_length,
            StringParserSettings parse_settings_in,
            UnitSystem output_unit_system,
            out double value_out,
            ref StringParserSettings parse_results,
            ref UnitSystem parsed_unit_system
            )
        {
            if (null == expression)
            {
                throw new ArgumentNullException();
            }

            IntPtr settings_in_ptr  = parse_settings_in.ConstPointer();
            IntPtr settings_out_ptr = null == parse_results ? IntPtr.Zero : parse_results.NonConstPointer();

            value_out          = RhinoMath.UnsetValue;
            parsed_unit_system = UnitSystem.None;

            int rc = UnsafeNativeMethods.ON_Parse_LengthExpression(
                expression,
                start_offset,
                expression_length,
                settings_in_ptr,
                output_unit_system,
                ref value_out,
                settings_out_ptr,
                ref parsed_unit_system);

            return(rc);
        }
示例#3
0
        /// <summary>
        /// Parse a string expression to get a number
        /// </summary>
        /// <param name="expression">
        ///  String to parse
        /// </param>
        /// <param name="max_count">
        ///  Maximum number of characters to parse
        /// </param>
        /// <param name="settings_in">
        ///  Determines what input will be parsed
        /// </param>
        /// <param name="settings_out">
        ///  Reports the results of the parse operation
        /// </param>
        /// <param name="answer">
        ///  The number result of the parse operation
        /// </param>
        /// <returns>
        /// Count of characters in expression parsed
        /// if ParseNumber() returns 0, parse was unsuccessful
        /// </returns>
        /// <since>6.0</since>
        public static int ParseNumber(
            string expression,
            int max_count,
            StringParserSettings settings_in,
            ref StringParserSettings settings_out,
            out double answer
            )
        {
            if (null == expression)
            {
                throw new ArgumentNullException();
            }
            if (null == settings_in)
            {
                throw new ArgumentNullException();
            }
            answer = RhinoMath.UnsetValue;

            int    rc           = 0;
            IntPtr settings_ptr = settings_in.ConstPointer();
            IntPtr results_ptr  = null == settings_out ? IntPtr.Zero : settings_out.NonConstPointer();

            rc = UnsafeNativeMethods.ON_ParseDouble(expression, max_count, settings_ptr, results_ptr, ref answer);
            return(rc);
        }