elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Curso de javascript por TickTack


  Mostrar Temas
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14
41  Foros Generales / Foro Libre / Alguien sabe que serie es? en: 3 Mayo 2011, 09:31 am
.
Me parecio divertida y buena para pasar el rato alguien sabe cual serie es?



Dulces Lunas!¡.
42  Programación / Programación C/C++ / cls_Byte ( Funciones Binarias ) ByteReplace, ByteSplit, ByteMid, ByteExits... en: 27 Abril 2011, 00:32 am
.
Tal vez a alguien le sirva esta clase que me hice para manipular un conjunto de bytes similar como vb6 las cadenas y evitarme el ajetreo de detectar los desgraciados memory leak que a mas de uno nos frustan el desarrollo/ejecucion de un programa, aun que por hay deben haber algunos agujeros... pero aun así ya funciona y eso es lo que me interesaba realmente. para mi trabajo de universidad.

Disculpen po no usar new() ni delete() para cargar las clases.

cls_byte.h
Código
  1.  
  2. #ifndef _CLS_BYTE_H_
  3. #define _CLS_BYTE_H_
  4.  
  5. #include <fstream>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "Bytes/modutiles.h"
  9.  
  10. //    #include <stdbool.h> <-- C ANSI... (C99)CLS_BYTE_CPP
  11.  
  12. class cls_byte;
  13.  
  14. #ifndef Struct_clsByte_
  15. #define Struct_clsByte_
  16. struct Struct_clsByte
  17. {
  18.    cls_byte    *pbyt_class;
  19.    size_t      szt_count;
  20. };
  21. #endif  // Struct_clsByte_
  22.  
  23. class cls_byte
  24. {
  25. private:
  26.    size_t        szt_len;
  27.    Byte          *pbyt_data;
  28. public:
  29.    cls_byte();
  30.    ~cls_byte();
  31.  
  32.    size_t           Getlen ( );
  33.    Byte       *GetBytesPtr ( );
  34.    struct Struct_Byte *GetBytes ( );
  35.  
  36.    Byte          *SetBytes ( Byte *pByt_Bytes , size_t szt_lnBytes );  // ok
  37.    Byte          *SetBytes ( cls_byte     *pclsbyteFind );
  38.    Byte          *SetBytes ( Struct_Byte  *pclsbyteFind );             // ok
  39.  
  40.    bool            SetBytesFromFile( const char *pcchr );
  41.    bool            SetBytesFromFile( const char *pcchr , size_t szt_ini );
  42.    bool            SetBytesFromFile( const char *pcchr , size_t szt_ini , long lng_len );
  43.  
  44.    cls_byte       *Mid     ( size_t szt_start , size_t szt_len );
  45.    cls_byte       *Mid     ( size_t szt_start );
  46.  
  47.    Struct_clsByte *Split   ( Byte *pbyt_delimiter , size_t szt_lndelimiter , long lng_limit );
  48.    Struct_clsByte *Split   ( Byte *pbyt_delimiter , size_t szt_lndelimiter );
  49.    Struct_clsByte *Split   ( cls_byte *pclsbytelim , long lng_limit );
  50.    Struct_clsByte *Split   ( cls_byte *pclsbytelim );
  51.  
  52.    cls_byte       *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement );
  53.    cls_byte       *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start );
  54.    cls_byte       *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count );
  55.    cls_byte       *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacemente , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare );
  56.    cls_byte       *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement );
  57.    cls_byte       *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start );
  58.    cls_byte       *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count );
  59.    cls_byte       *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare );
  60.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente );
  61.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente , size_t szt_Start );
  62.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente , size_t szt_Start , long lng_Count );
  63.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare );
  64.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement );
  65.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start );
  66.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count );
  67.    cls_byte       *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare );
  68.  
  69.    size_t            Index ( cls_byte *pclsbyte );
  70.    size_t            Index ( cls_byte *pclsbyte , size_t szt_Start );
  71.    size_t            Index ( cls_byte *pclsbyte , size_t szt_Start , e_CompareMethod enum_Compare );
  72.    size_t            Index ( Byte *pByt_Find , size_t szt_lsf );
  73.    size_t            Index ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start );
  74.    size_t            Index ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start , e_CompareMethod enum_Compare );
  75.  
  76.    bool              Exits ( cls_byte *pclsbyte );
  77.    bool              Exits ( cls_byte *pclsbyte , size_t szt_Start );
  78.    bool              Exits ( cls_byte *pclsbyte , size_t szt_Start , long lng_interval );
  79.    bool              Exits ( cls_byte *pclsbyte , size_t szt_Start , long lng_interval , e_CompareMethod enum_Compare );
  80.    bool              Exits ( Byte *pByt_Find , size_t szt_lsf );
  81.    bool              Exits ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start );
  82.    bool              Exits ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start , long lng_interval );
  83.    bool              Exits ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start , long lng_interval , e_CompareMethod enum_Compare );
  84. };
  85. //    #include "cls_byte.cpp"
  86. #endif // CLS_BYTE_H
  87.  
  88.  

cls_byte.cpp
Código
  1.  
  2. #ifndef _CLS_BYTE_CPP
  3. #define _CLS_BYTE_CPP 1
  4.  
  5.    #include "cls_byte.h"
  6.  
  7.    cls_byte::cls_byte()
  8.    {
  9.        this->szt_len   = 0;
  10.        this->pbyt_data  = NULL;
  11.    }
  12.  
  13.    cls_byte::~cls_byte()
  14.        { setnewptrf<Byte*>( this->pbyt_data , NULL ); }
  15.  
  16.    size_t cls_byte::Getlen()
  17.        { return this->szt_len; }
  18.  
  19.    Byte *cls_byte::GetBytesPtr()
  20.        { return this->pbyt_data; }
  21.  
  22.    bool cls_byte::SetBytesFromFile(const char *pcchr)
  23.        { return this->SetBytesFromFile( pcchr , 0 , -1 ); }
  24.    bool cls_byte::SetBytesFromFile(const char *pcchr, size_t szt_ini)
  25.        { return this->SetBytesFromFile( pcchr , szt_ini , -1 ); }
  26.    bool cls_byte::SetBytesFromFile(const char *pcchr, size_t szt_ini, long lng_len)
  27.        {
  28.            FILE            *hfile              = fopen( pcchr , "r+b" );
  29.            Struct_Byte     stbyt_data          = { NULL , 0 };
  30.            size_t          szt_end             = 0;
  31.  
  32.            if ( hfile != NULL )
  33.            {
  34.                stbyt_data.szt_lenbytes             = flen( hfile );
  35.                if ( lng_len <= -1 )
  36.                    lng_len                             = stbyt_data.szt_lenbytes;
  37.                szt_end = 0;
  38.                if ( fix_numbers_range<size_t>( &szt_ini , &szt_end , &lng_len , NULL ,  0 , stbyt_data.szt_lenbytes-1 ) == true )
  39.                {
  40.                    stbyt_data.pbyt_bytes       = (Byte*)malloc(sizeof(Byte)*lng_len);
  41.                    fseek       ( hfile , (long)szt_ini , SEEK_SET);
  42.                    fread       ( (char*)stbyt_data.pbyt_bytes , 1 , lng_len ,  hfile );
  43.                }
  44.                stbyt_data.szt_lenbytes     = (size_t)lng_len;
  45.                fclose      ( hfile );
  46.                this->SetBytes( &stbyt_data );
  47.            }
  48.  
  49.        }
  50.    Byte *cls_byte::SetBytes(Struct_Byte *pclsbyteFind)
  51.        { return this->SetBytes( pclsbyteFind->pbyt_bytes , pclsbyteFind->szt_lenbytes ); }
  52.    Byte *cls_byte::SetBytes(cls_byte *pclsbyteFind)
  53.        { return this->SetBytes( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() ); }
  54.    Byte *cls_byte::SetBytes(Byte *pByt_Bytes, size_t szt_lnBytes)
  55.    {
  56.        this->szt_len = szt_lnBytes;
  57.        if ( setnewptrf<Byte*>( this->pbyt_data , ByteClone( pByt_Bytes , this->szt_len ) ) == NULL)
  58.        {
  59.            this->szt_len = 0;
  60.            return pByt_Bytes;
  61.        }
  62.        return NULL;
  63.    }
  64.  
  65.    Struct_Byte *cls_byte::GetBytes()
  66.    {
  67.        struct Struct_Byte *pstrbyt_ret = (Struct_Byte*)malloc(sizeof(Struct_Byte));
  68.        pstrbyt_ret->pbyt_bytes = ByteClone( this->pbyt_data , this->szt_len );
  69.        pstrbyt_ret->szt_lenbytes =  this->szt_len;
  70.        if ( pstrbyt_ret->pbyt_bytes == NULL )
  71.            pstrbyt_ret->szt_lenbytes = 0;
  72.        return pstrbyt_ret;
  73.    }
  74.  
  75.    size_t cls_byte::Index(Byte *pByt_Find, size_t szt_lsf)
  76.        { return ByteIndex( this->pbyt_data , this->szt_len  ,pByt_Find , szt_lsf ); }
  77.    size_t cls_byte::Index(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start)
  78.        { return ByteIndex( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start ); }
  79.    size_t cls_byte::Index(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start, e_CompareMethod enum_Compare)
  80.        { return ByteIndex( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start , enum_Compare ); }
  81.    size_t cls_byte::Index(cls_byte *pclsbyte)
  82.        { return ByteIndex( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len ); }
  83.    size_t cls_byte::Index(cls_byte *pclsbyte, size_t szt_Start)
  84.        { return ByteIndex( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start ); }
  85.    size_t cls_byte::Index(cls_byte *pclsbyte, size_t szt_Start, e_CompareMethod enum_Compare)
  86.        { return ByteIndex( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start , enum_Compare ); }
  87.  
  88.  
  89.    bool cls_byte::Exits(cls_byte *pclsbyte)
  90.        { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len ); }
  91.    bool cls_byte::Exits(cls_byte *pclsbyte, size_t szt_Start)
  92.        { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start ); }
  93.    bool cls_byte::Exits(cls_byte *pclsbyte, size_t szt_Start, long lng_interval)
  94.        { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start , lng_interval ); }
  95.    bool cls_byte::Exits(cls_byte *pclsbyte, size_t szt_Start, long lng_interval, e_CompareMethod enum_Compare)
  96.        { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start , lng_interval , enum_Compare ); }
  97.    bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf)
  98.        { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf ); }
  99.    bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start)
  100.        { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start ); }
  101.    bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start, long lng_interval)
  102.        { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start , lng_interval ); }
  103.    bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start, long lng_interval, e_CompareMethod enum_Compare)
  104.        { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start , lng_interval , enum_Compare ); }
  105.  
  106.  
  107.  
  108.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement )
  109.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , 0 , -1 , BINARY ); }
  110.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start )
  111.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , -1 , BINARY ); }
  112.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count )
  113.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , BINARY ); }
  114.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare )
  115.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , enum_Compare ); }
  116.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement )
  117.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , 0 , -1 , BINARY ); }
  118.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start )
  119.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , szt_Start , -1 , BINARY ); }
  120.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count )
  121.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , szt_Start , lng_Count , BINARY ); }
  122.    cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare )
  123.        { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , szt_Start , lng_Count , enum_Compare ); }
  124.    cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement )
  125.        { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , 0 , -1 , BINARY ); }
  126.    cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement , size_t szt_Start )
  127.        { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , -1 , BINARY ); }
  128.    cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count )
  129.        { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , BINARY ); }
  130.    cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare )
  131.        { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , enum_Compare ); }
  132.    cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement)
  133.        { return this->Replace( pByt_Find , szt_lnFind , pByt_Replacement , szt_lnReplacement , 0 , -1 , BINARY ); }
  134.    cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement, size_t szt_Start)
  135.        { return this->Replace( pByt_Find , szt_lnFind , pByt_Replacement , szt_lnReplacement , szt_Start , -1 , BINARY ); }
  136.    cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement, size_t szt_Start, long lng_Count)
  137.        { return this->Replace( pByt_Find , szt_lnFind , pByt_Replacement , szt_lnReplacement , szt_Start , lng_Count , BINARY ); }
  138.    cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement, size_t szt_Start, long lng_Count, e_CompareMethod enum_Compare)
  139.        {
  140.            cls_byte            *cls_Ret    = (cls_byte*)malloc(sizeof(cls_byte));
  141.            Struct_Byte         *pByt_Ret   = NULL;
  142.            Byte                *pByt_ClnF  = ByteClone ( pByt_Find , szt_lnFind );
  143.            Byte                *pByt_ClnR  = ByteClone ( pByt_Replacement , szt_lnReplacement );
  144.  
  145.            pByt_Ret                = ByteReplace( this->pbyt_data , this->szt_len , pByt_ClnF , szt_lnFind , pByt_ClnR , szt_lnReplacement , szt_Start , lng_Count , enum_Compare );
  146.            cls_Ret->SetBytes       ( pByt_Ret );
  147.  
  148.            setnewptrf<Byte*>        ( pByt_ClnF , NULL );
  149.            setnewptrf<Byte*>        ( pByt_ClnR , NULL );
  150.            setnewptrf<Byte*>        ( pByt_Ret->pbyt_bytes , NULL );
  151.            setnewptrf<Struct_Byte*> ( pByt_Ret , NULL );
  152.  
  153.            return cls_Ret;
  154.        }
  155.    cls_byte *cls_byte::Mid(size_t szt_start)
  156.        { return this->Mid   ( szt_start , this->szt_len ); }
  157.    cls_byte *cls_byte::Mid(size_t szt_start, size_t szt_len)
  158.        {
  159.            cls_byte            *cls_Ret    = (cls_byte*)malloc(sizeof(cls_byte));
  160.            Struct_Byte         *pByt_Ret   = NULL;
  161.  
  162.            pByt_Ret                = ByteMid ( this->pbyt_data , this->szt_len , szt_start , szt_len );
  163.            cls_Ret->SetBytes       ( pByt_Ret );
  164.  
  165.            setnewptrf<Byte*>        ( pByt_Ret->pbyt_bytes , NULL );
  166.            setnewptrf<Struct_Byte*> ( pByt_Ret , NULL );
  167.  
  168.            return cls_Ret;
  169.        }
  170.  
  171.    Struct_clsByte *cls_byte::Split(Byte *pbyt_delimiter, size_t szt_lndelimiter)
  172.        { return this->Split ( pbyt_delimiter , szt_lndelimiter , -1 ); }
  173.    Struct_clsByte *cls_byte::Split(Byte *pbyt_delimiter, size_t szt_lndelimiter, long lng_limit)
  174.        {
  175.            Struct_clsByte      *cls_Ret    = (Struct_clsByte*)malloc(sizeof(Struct_clsByte));
  176.            Struct_Byte_Split   *pByt_Ret   = NULL;
  177.            Byte                *pByt_Clone = ByteClone ( pbyt_delimiter , szt_lndelimiter );
  178.  
  179.            pByt_Ret                = ByteSplit ( this->pbyt_data , this->szt_len , pByt_Clone , szt_lndelimiter , lng_limit );
  180.  
  181.            cls_Ret->szt_count      = 0;
  182.            cls_Ret->pbyt_class     = (cls_byte*)malloc(sizeof(cls_byte)*pByt_Ret->szt_ln);
  183.  
  184.            for ( cls_Ret->szt_count=0 ; cls_Ret->szt_count<pByt_Ret->szt_ln ; ++cls_Ret->szt_count )
  185.            {
  186.                cls_Ret->pbyt_class[ cls_Ret->szt_count ].SetBytes( pByt_Ret->Struct[ cls_Ret->szt_count ] );
  187.                setnewptrf<Byte*>        ( pByt_Ret->Struct[ cls_Ret->szt_count ]->pbyt_bytes , NULL );
  188.                setnewptrf<Struct_Byte*> ( pByt_Ret->Struct[ cls_Ret->szt_count ] , NULL );
  189.            }
  190.  
  191.            setnewptrf<Byte*>                ( pByt_Clone , NULL );
  192.            setnewptrf<Struct_Byte_Split*>   ( pByt_Ret , NULL );
  193.  
  194.            return cls_Ret;
  195.        }
  196.    Struct_clsByte *cls_byte::Split(cls_byte *pclsbytelim)
  197.        { return this->Split ( pclsbytelim->GetBytesPtr() , pclsbytelim->Getlen() , -1 ); }
  198.    Struct_clsByte *cls_byte::Split(cls_byte *pclsbytelim, long lng_limit)
  199.        { return this->Split ( pclsbytelim->GetBytesPtr() , pclsbytelim->Getlen() , lng_limit ); }
  200.  
  201. #endif
  202.  
  203.  

Temibles Lunas!¡.
43  Foros Generales / Sugerencias y dudas sobre el Foro / [Error Foro] Post en: 18 Abril 2011, 19:10 pm

http://foro.elhacker.net/programacion_visual_basic/movido_vb_iquestcomo_hacer_para_parar_el_timer-t325028.0.html

Dulces Lunas!¡.
44  Foros Generales / Foro Libre / Goku de tepito... en: 10 Abril 2011, 07:12 am
.
Este baboso me toco verlo hace tiempo en persona, por hay me veo... la cuestion es donde, el idiota segun se lo hizo por 20$ pesos ( como 1 dolar y medio ).

Goku de Tepito

es una idiotes pero me hizo cagar de risa.

Dulces Lunas!¡.
45  Foros Generales / Foro Libre / Ayuda matematica- en: 9 Abril 2011, 03:14 am
.
Coordenadas esfericas.

OJO mis ejes Z y X son el piso y mi eje Y es mi altitud., de donde Z es lo que se define como que tan seca o lejos esta de un objeto.

Como se calcula en angulo azimutal de dos puntos?

x = d * sin(a) * cos(e)
y = d * sin(e)
z = d * cos(a) * cos(e)

donde:

d = distancia entre dos puntos ( X,Y,Z )
a = angulo azimutal
e = angulo de elevacion

hasta ahora ya pude saber como saber el angulo de elevacion de un punto con respecto al punto origen

e = csc( y/d )

Pero para el angulo de la azimutal

[Aqui empiza mi duca sigan leyendo]

llego a un punto muerto donde ya no se que rayos hacer.

El angulo azimutal involucra a el eje x y el eje z, el eje y solo es involucrado por la elevacion ( Logica Basica )

x = d * sin(a) * cos(e)
z = d * cos(a) * cos(e)

Entonces empesando a despejar

Como en ambas expresiones existen d y cos(e) puedo hacer un reemplazo de terminos asi:

Quitando a cos(e) para simplificar la cosa:

cos(e) = x / ( d*sin(a) )

En la segunda formula reemplazo (  z = d * cos(a) * cos(e) )

z = d * cos(a) * x / ( d*sin(a) )

Simplificando un poco queda:

z = cos(a) * x /  sin(a)

y tratando de despejar a el angulo a obtengo:

z/x = cos(a) / sin(a)    siendo lo mismo a:      z/x = cos(a) * csc(a)

por lo tanto:

cosec ( z/x ) = a * csc( a )
sin(cosec(z/x)) = a*a

por lo tanto

raiz( sin(cosec(z/x)) ) = a

pero al aplicar dicho despeje no me da el angulo ya mensionado. alguien sabe como solucionarlo?

Dulces Lunas!¡.
.
46  Foros Generales / Sugerencias y dudas sobre el Foro / [error en el foro] mien... en: 8 Abril 2011, 19:24 pm
....
vean este tema... dice que lo creo el usuario DesSy pero solo se ve mi poublicacion ...

http://foro.elhacker.net/programacion_visual_basic/ayuda_iquestcomo_se_puede_ejecutar_pagina_web_clickeando_en_un_label_en_vb6-t324107.0.html

Dulces Lunas!¡.
47  Programación / Programación Visual Basic / [Source] WinCenterIn ( Centrar Objetos con respecto a otros ). en: 9 Marzo 2011, 04:31 am
.
mmm en lugar de solo criticar la funcion pondre una de mi tutela que uso para esto, es decir centrar las cosas por medio de su hWnd, Sirve con:

* Objetos del form ( Botones, frames, etc... ).
* Ventanas ( de la aplicacion o externas ).
* Pantalla  ( Centra el objeto con restecto a la pantalla ).
* Funciona con TODO lo que tenga un hWnd valido.

Codigo Actualizado:

Código
  1.  
  2. '
  3. ' ////////////////////////////////////////////////////////////////
  4. ' // Autor: BlackZeroX ( Ortega Avila Miguel Angel )            //
  5. ' //                                                            //
  6. ' // Web: http://InfrAngeluX.Sytes.Net/                         //
  7. ' //                                                            //
  8. ' // |-> Pueden Distribuir Este C&#243;digo siempre y cuando         //
  9. ' // no se eliminen los cr&#233;ditos originales de este c&#243;digo      //
  10. ' // No importando que sea modificado/editado o engrandecido    //
  11. ' // o achicado, si es en base a este c&#243;digo                    //
  12. ' ////////////////////////////////////////////////////////////////
  13. ' //
  14. ' ////////////////////////////////////////////////////////////////
  15.  
  16. Option Explicit
  17.  
  18. Private Type POINTAPI
  19.    x       As Long
  20.    y       As Long
  21. End Type
  22. Private Type RECT
  23.    Left    As Long
  24.    Top     As Long
  25.    Right   As Long
  26.    Bottom  As Long
  27. End Type
  28.  
  29. Enum WS_InCenterOpt
  30.    InScreen = 0
  31.    InObject = 1
  32.    InParent = 2
  33.    InWinExtern = 3
  34. End Enum
  35.  
  36. Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
  37. Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
  38. Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  39. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  40. Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
  41.  
  42. Public Function WinCenterIn(ByVal hwnd As Long, Optional ByVal InhWnd As Long = 0, Optional ByVal Opt As WS_InCenterOpt = InParent)
  43. Dim st_retm         As RECT
  44. Dim st_retd         As RECT
  45. Dim st_pt           As POINTAPI
  46.  
  47.    If GetWindowRect(hwnd, st_retm) <> 0 Then
  48.  
  49.        Select Case Opt
  50.  
  51.            Case InObject, InParent, InWinExtern
  52.                If Opt = InParent Then
  53.                    InhWnd = GetParent(hwnd)
  54.                    If InhWnd = 0 Then
  55.                        WinCenterIn = WinCenterIn(hwnd, 0, InScreen)
  56.                    End If
  57.                End If
  58.                If GetWindowRect(InhWnd, st_retd) = 0 Then
  59.                    Exit Function
  60.                End If
  61.  
  62.            Case InScreen
  63.                st_retd.Bottom = GetSystemMetrics(&H1)
  64.                st_retd.Right = GetSystemMetrics(&H0)
  65.  
  66.            Case Else
  67.                Exit Function
  68.  
  69.        End Select
  70.  
  71.        st_pt.x = st_retd.Left + ((st_retd.Right - st_retd.Left) - (st_retm.Right - st_retm.Left)) \ 2
  72.        st_pt.y = st_retd.Top + ((st_retd.Bottom - st_retd.Top) - (st_retm.Bottom - st_retm.Top)) \ 2
  73.  
  74.        If Opt <> InWinExtern Then
  75.            Call ScreenToClient(InhWnd, st_pt)
  76.        End If
  77.  
  78.        WinCenterIn = MoveWindow(hwnd, st_pt.x, st_pt.y, (st_retm.Right - st_retm.Left), (st_retm.Bottom - st_retm.Top), 1) <> 0
  79.  
  80.    End If
  81.  
  82. End Function
  83.  
  84.  

Ejemplo:

Código
  1.  
  2. Option Explicit
  3.  
  4. Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  5.  
  6. Private Sub Command2_Click()
  7.    WinCenterIn Me.hwnd
  8.    WinCenterIn FindWindowA(vbNullString, "Administrador de tareas de Windows"), Me.hwnd, InWinExtern
  9.    'WinCenterIn Me.hwnd, FindWindowA(vbNullString, "Administrador de tareas de Windows"), InWinExtern
  10. End Sub
  11.  
  12.  

Version Anterior:

Código:

'
' ////////////////////////////////////////////////////////////////
' // Autor: BlackZeroX ( Ortega Avila Miguel Angel )            //
' //                                                            //
' // Web: http://InfrAngeluX.Sytes.Net/                         //
' //                                                            //
' // |-> Pueden Distribuir Este Código siempre y cuando         //
' // no se eliminen los créditos originales de este código      //
' // No importando que sea modificado/editado o engrandecido    //
' // o achicado, si es en base a este código                    //
' ////////////////////////////////////////////////////////////////
' //
' ////////////////////////////////////////////////////////////////

Option Explicit

Private Type POINTAPI
    x       As Long
    y       As Long
End Type
Private Type RECT
    Left    As Long
    Top     As Long
    Right   As Long
    Bottom  As Long
End Type

Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

Public Function WinCenterIn(ByVal hwnd As Long, Optional ByVal InhWnd As Long = 0, Optional ByVal WinExterna As Boolean)
Dim st_retm         As RECT
Dim st_retd         As RECT
Dim st_pt           As POINTAPI


    If GetWindowRect(hwnd, st_retm) = 0 Then
        Exit Function
    End If
   
    If InhWnd = 0 Then
        st_retd.Bottom = GetSystemMetrics(&H1)
        st_retd.Right = GetSystemMetrics(&H0)
    Else
        If GetWindowRect(InhWnd, st_retd) = 0 Then
            Exit Function
        End If
    End If
   
    st_pt.x = st_retd.Left + (Abs((st_retd.Right - st_retd.Left) - (st_retm.Right - st_retm.Left))) \ 2
    st_pt.y = st_retd.Top + (Abs((st_retd.Bottom - st_retd.Top) - (st_retm.Bottom - st_retm.Top))) \ 2
   
    If Not WinExterna And InhWnd = 0 Then
        Call ScreenToClient(InhWnd, st_pt)
    Else
        Call ScreenToClient(InhWnd, st_pt)
        st_pt.x = st_pta.x + st_pt.x
        st_pt.y = st_pta.y + st_pt.y
    End If
    WinCenterIn = MoveWindow(hwnd, st_pt.x, st_pt.y, (st_retm.Right - st_retm.Left), (st_retm.Bottom - st_retm.Top), 1) <> 0
   
End Function


La implementacion es bastante sencilla.

Código
  1.  
  2. WinCenterIn Command1.hwnd, Me.hwnd
  3. WinCenterIn Command1.hwnd, 0
  4. WinCenterIn me.hwnd, 0
  5.  
  6.  

Temibles Lunas!¡.
48  Programación / Programación C/C++ / Error OpenGL. en: 5 Marzo 2011, 12:23 pm
.
bueno ando provando OpenGL en C++ y todo perfecto con GLUT, pero cuando intento usar las apis:

Código
  1.  
  2.    glClearColor(0.0,0.0,0.0,0.0);
  3.    glClear(GL_COLOR_BUFFER_BIT);
  4.    glMatrixMode(GL_PROJECTION);
  5.    glLoadIdentity();
  6.    glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
  7.    glMatrixMode(GL_MODELVIEW);
  8.    glBegin(GL_TRIANGLES);
  9.    glColor3f(1.0,0.0,0.0);
  10.    glVertex3f(0.0,0.8,0.0);
  11.    glColor3f(0.0,1.0,0.0);
  12.    glVertex3f(-0.6,-0.2,0.0);
  13.    glColor3f(0.0,0.0,1.0);
  14.    glVertex3f(0.6,-0.2,0.0);
  15.    glEnd();
  16.    glFlush();
  17.  
  18.  

Me sale error de undefined reference to ´...´ a cada una de estas apis.

caso contrario con:

Código
  1.  
  2.    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
  3.    glutInitWindowPosition(20,20);
  4.    glutInitWindowSize(500,500);
  5.    glutCreateWindow((const char*)&argv[0]);
  6.    glutDisplayFunc(display);
  7.    glutMainLoop();
  8.  
  9.  

Que me falta linkear?.

P.D.: tengo el linkeada la libreria glut32.lib, en el proyecto.

Dulces Lunas!¡.
49  Programación / Programación Visual Basic / [!] Liga interesante; Programando microcontroladores. en: 1 Marzo 2011, 08:07 am
.
El compilador se llama Great Cow Basic y sirve para programar en los microchips.

* Es de codigo abierto.
* Free.
* Instalacion en Windows y Linux.
* Las variables tal y como son declaras, se ven reflejados en el codigo ASM final es decir no agrega nombres raros al codigo ASM final.

Manual es Español

http://gcbasic.sourceforge.net/index.html

Código
  1.  
  2. 'Led parpadeante
  3.  
  4. #chip 16F628A, 20      'modelo de pic y velocidad de reloj: 20 Mhz
  5.  
  6. #define led PORTB.1
  7.  
  8. Main:
  9.    TRISB=0
  10.    PORTB=0
  11.  
  12.    led = 1
  13.    wait 500 ms
  14.    led = 0
  15.    wait 500 ms
  16.  
  17. goto Main
  18.  
  19.  

Codigo ASM generado de manera limpia.

Código
  1.  
  2. ;Program compiled by Great Cow BASIC (0.9 13/9/2008)
  3. ;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
  4. ;check the documentation or email w_cholmondeley@users.sourceforge.net.
  5.  
  6. ;********************************************************************************
  7.  
  8. ;Set up the assembler options (Chip type, clock source, other bits and pieces)
  9. LIST p=16F628A, r=DEC
  10. #include
  11. __CONFIG _HS_OSC & _WDT_OFF & _LVP_OFF & _MCLRE_OFF
  12.  
  13. ;********************************************************************************
  14.  
  15. ;Set aside memory locations for variables
  16. DELAYTEMP   equ    32
  17. DELAYTEMP2   equ    33
  18. RANDOMSEED   equ    34
  19. RANDOMSEED_H   equ    35
  20. SysWaitTempMS   equ    36
  21. SysWaitTempMS_H   equ    37
  22.  
  23. ;********************************************************************************
  24.  
  25. ;Jump to initialisation code when PIC is reset
  26.    ORG    0
  27.    call    INITSYS
  28.    goto    SystemInitialise
  29.  
  30. ;********************************************************************************
  31.  
  32. ;Interrupt vector
  33.    ORG    4
  34. ;Various initialisation routines, automatically called by GCBASIC
  35. SystemInitialise
  36.  
  37. ;********************************************************************************
  38.  
  39. ;Start of the main program
  40. MAIN
  41.    banksel    TRISB
  42.    clrf    TRISB
  43.    banksel    PORTB
  44.    clrf    PORTB
  45.    bsf    PORTB,1
  46.    movlw    244
  47.    movwf    SysWaitTempMS
  48.    movlw    1
  49.    movwf    SysWaitTempMS_H
  50.    call    Delay_MS
  51.    bcf    PORTB,1
  52.    movlw    244
  53.    movwf    SysWaitTempMS
  54.    movlw    1
  55.    movwf    SysWaitTempMS_H
  56.    call    Delay_MS
  57.    goto    MAIN
  58. BASPROGRAMEND
  59.    sleep
  60.    goto    $
  61.  
  62. ;********************************************************************************
  63. ;Subroutines included in program
  64. ;********************************************************************************
  65.  
  66. Delay_MS
  67.    incf    SysWaitTempMS_H, F
  68. DMS_START
  69.    movlw    10
  70.    movwf    DELAYTEMP2
  71. DMS_OUTER
  72.    movlw    166
  73.    movwf    DELAYTEMP
  74. DMS_INNER
  75.    decfsz    DELAYTEMP, F
  76.    goto    DMS_INNER
  77.    decfsz    DELAYTEMP2, F
  78.    goto    DMS_OUTER
  79.    decfsz    SysWaitTempMS, F
  80.    goto    DMS_START
  81.    decfsz    SysWaitTempMS_H, F
  82.    goto    DMS_START
  83.    return
  84.  
  85. ;********************************************************************************
  86.  
  87. INITSYS
  88.    movlw    7
  89.    movwf    CMCON
  90.    clrf    PORTA
  91.    clrf    PORTB
  92.    return
  93.  
  94. ;********************************************************************************
  95.  
  96. END
  97.  
  98.  

Dulces Lunas!¡.
50  Programación / Programación Visual Basic / [!] Liga interesante, haciendo un S.O. en lenguaje Basic. en: 20 Febrero 2011, 00:25 am
.

Bueno ya NO pueden decir que no se puede hacer un S.O.. en el lenguaje Basic ni denigrarlo tanto.

http://wiki.osdev.org/FreeBasic_Barebones

Dulces Lunas!¡.
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines