Changeset 3250
- Timestamp:
- Feb 16, 2005, 5:22:06 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/archive/psdb/psDB.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/psdb/psDB.c
r3249 r3250 8 8 * @author Joshua Hoblitt 9 9 * 10 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-02-17 03:2 0:56 $10 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-02-17 03:22:06 $ 12 12 * 13 13 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 67 67 static psPtr psDBGetPTypeNaN(psElemType pType); 68 68 static bool psDBIsPTypeNaN(psElemType pType, psPtr data); 69 static char *psDBPTypeAsString(psPtr data, psElemType pType);70 69 71 70 // string utility functions … … 1545 1544 } 1546 1545 1547 #define PS_PTYPE_TO_STR(type, format, data) \1548 (size_t)log10((double)*(type *)data) + 1; \1549 string = psAlloc(length); \1550 snprintf(string, length, format, *(type *)data);1551 1552 static char *psDBPTypeAsString(psPtr data, psElemType pType)1553 {1554 size_t length;1555 char *string;1556 1557 // formats are a portability issue1558 switch (pType) {1559 case PS_TYPE_S8:1560 length = PS_PTYPE_TO_STR(psS8, "%i", data);1561 break;1562 case PS_TYPE_S16:1563 length = PS_PTYPE_TO_STR(psS16, "%i", data);1564 break;1565 case PS_TYPE_S32:1566 length = PS_PTYPE_TO_STR(psS32, "%i", data);1567 break;1568 case PS_TYPE_S64:1569 length = PS_PTYPE_TO_STR(psS64, "%li", data);1570 break;1571 case PS_TYPE_U8:1572 length = PS_PTYPE_TO_STR(psU8, "%u", data);1573 break;1574 case PS_TYPE_U16:1575 length = PS_PTYPE_TO_STR(psU16, "%u", data);1576 break;1577 case PS_TYPE_U32:1578 length = PS_PTYPE_TO_STR(psU32, "%u", data);1579 break;1580 case PS_TYPE_U64:1581 length = PS_PTYPE_TO_STR(psU64, "%lu", data);1582 break;1583 case PS_TYPE_F32:1584 length = PS_PTYPE_TO_STR(psF32, "%f", data);1585 break;1586 case PS_TYPE_F64:1587 length = PS_PTYPE_TO_STR(psF32, "%f", data);1588 break;1589 case PS_TYPE_C32:1590 // this is a bogus SQL type1591 break;1592 case PS_TYPE_C64:1593 // this is a bogus SQL type1594 break;1595 case PS_TYPE_BOOL:1596 length = PS_PTYPE_TO_STR(bool, "%u", data);1597 break;1598 case PS_TYPE_PTR:1599 // unsafe to convert unless it's a string1600 break;1601 }1602 1603 return string;1604 }1605 1606 1546 1607 1547 // string utility functions
Note:
See TracChangeset
for help on using the changeset viewer.
