File indexing completed on 2024-05-12 16:36:43

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2010 Thorsten Zachmann <zachmann@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (  at your option ) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KPRDURATIONPARSER_H
0021 #define KPRDURATIONPARSER_H
0022 
0023 class QString;
0024 
0025 /**
0026  * This implements a parser for clock values as defined in SMIL 2.0, 10.3.1 Attributes
0027  * Clock values                                                                                                                  
0028  * 
0029  * Clock values have the following syntax:                                                                                   
0030  * 
0031  *     Clock-value         ::= ( Full-clock-value | Partial-clock-value | Timecount-value )                                     
0032  *     Full-clock-value    ::= Hours ":" Minutes ":" Seconds ("." Fraction)?                                                   
0033  *     Partial-clock-value ::= Minutes ":" Seconds ("." Fraction)?                                                             
0034  *     Timecount-value     ::= Timecount ("." Fraction)? (Metric)?                                                           
0035  *     Metric              ::= "h" | "min" | "s" | "ms"                                                                          
0036  *     Hours               ::= DIGIT+; any positive number                                                                       
0037  *     Minutes             ::= 2DIGIT; range from 00 to 59                                                                       
0038  *     Seconds             ::= 2DIGIT; range from 00 to 59                                                                       
0039  *     Fraction                ::= DIGIT+                                                                                        
0040  *     Timecount           ::= DIGIT+                                                                                            
0041  *     2DIGIT                    ::= DIGIT DIGIT                                                                                 
0042  *     DIGIT                        ::= [0-9]                                                                                    
0043  * 
0044  * For Timecount values, the default metric suffix is "s" (for seconds). No embedded white 
0045  * space is allowed in clock values, although leading and trailing white space characters 
0046  * will be ignored.                                                                     
0047  * 
0048  * The following are examples of legal clock values:                                                                             
0049  * 
0050  * o Full clock values:                                                                                                            
0051  *     02:30:03     = 2 hours, 30 minutes and 3 seconds                                                                          
0052  *     50:00:10.25  = 50 hours, 10 seconds and 250 milliseconds                                                                  
0053  * o Partial clock value:                                                                                                          
0054  *     02:33    = 2 minutes and 33 seconds                                                                                       
0055  *     00:10.5  = 10.5 seconds = 10 seconds and 500 milliseconds                                                                 
0056  * o Timecount values:                                                                                                             
0057  *     3.2h     = 3.2 hours = 3 hours and 12 minutes                                                                             
0058  *     45min    = 45 minutes                                                                                                     
0059  *     30s      = 30 seconds                                                                                                     
0060  *     5ms      = 5 milliseconds                                                                                                 
0061  *     12.467   = 12 seconds and 467 milliseconds                                                                                
0062  * 
0063  * Fractional values are just (base 10) floating point definitions of seconds. The number
0064  * of digits allowed is unlimited (although actual precision may vary among implementations).                                                                                   
0065  * For example:                                                                                                                  
0066  *     00.5s = 500 milliseconds                                                                                                  
0067  *     00:00.005 = 5 milliseconds                                                                                                
0068  *  */
0069 class KPrDurationParser
0070 {
0071 public:
0072     static int durationMs(const QString & duration);
0073     static QString msToString(const int ms);
0074 
0075 };
0076 
0077 #endif /* KPRDURATIONPARSER_H */