As my interest has been with RF, with PWM & PPM and with defined protocols, I've never needed to use the generalized method so I have no code. Also, most PICs (all but PIC18) are limited to a maximum array size of 256 bits. If we sample every 50µS (0.00005 secs) 256 bits can only record 0.00005x256=0.0128 secs or 12.8mS which is less than 1/10 the length of some IR codes.

This method was used by dedicated IR devices such as Slink-e and Ocelot which had more powerful processors and much more memory (external to the processor).