Nail Gun for Framing and installing subfloor
Most framing nailers will accept a variety of nail lengths.  For example, mine will take nails between 2" and 3.5" (6d to 16d equivalent) and from casual searching this seems to be fairly typical.

That said, you'd be much better off screwing down the sub-floor with decking screws. It's a little bit more work, but you won't have to worry about the nails working themselves out over time due to the deflection of people walking on it.

As far as roofing or hardwood flooring installation, both would require a different gun.  Framing nailers aren't designed to accommodate the larger heads on roofing nails, and likely won't ever be - in general, you don't want the nail heads to be much smaller than the nose-piece.  The more space you have between the nail head and the bore, the higher the chance of misfires or jams.  This is also the reason that most roofing nailers are coil fed instead of stick fed. 

Hardwood flooring nailers are fairly specialized equipment because they are designed for precisely blind nailing through the flooring tongues:



Image courtesy of Amazon.com, does not constitute an endorsement of either the specific tool or seller.

They also use a fastener that is much more like a finish nail than a framing nail.  Unless you're planning on doing a lot of roofs or a lot of floors, I'd compare the price of renting a roofing nailer or flooring nailer before purchasing one.